async function loadImages(filepath) {
  if (!fs.existsSync(filepath)) {
    console.log(`Data File: ${filepath} does not exist.
      Please see the README for instructions on how to download it`);
    process.exit(1);
  }

  const buffer = await readFile(filepath)

  const headerBytes = IMAGE_HEADER_BYTES;
  const recordBytes = IMAGE_HEIGHT * IMAGE_WIDTH;

  const headerValues = loadHeaderValues(buffer, headerBytes);
  assert.equal(headerValues[0], IMAGE_HEADER_MAGIC_NUM);
  assert.equal(headerValues[2], IMAGE_HEIGHT);
  assert.equal(headerValues[3], IMAGE_WIDTH);

  const images = [];
  let index = headerBytes;
  while (index < buffer.byteLength) {
    const array = new Float32Array(recordBytes);
    for (let i = 0; i < recordBytes; i++) {
      // Normalize the pixel values into the 0-1 interval, from
      // the original 0-255 interval.
      array[i] = buffer.readUInt8(index++) / 255;
    }
    images.push(array);
  }

  assert.equal(images.length, headerValues[1]);
  tf.util.shuffle(images);
  return images;
}
Load the images from the given file and normalize the data to 0-1 range.

Input file should be in the MNIST/FashionMNSIT file format

@param {string} filepath

@returns {Float32Array[]} an array of images represented as typed arrays.