code: def _extract_mnist_images(image_filepath: str) -> ndarray:
      with open(image_filepath, "rb") as bytestream:
          magic = _read32(bytestream)
          if magic != 2051:
              invalidInputError(
                  False,
                  "Invalid magic number %d in MNIST image file: %s"
                  % (magic, image_filepath),
              )
          num_images = _read32(bytestream)
          rows = _read32(bytestream)
          cols = _read32(bytestream)
          buf = bytestream.read(int(rows * cols * num_images))
          data = np.frombuffer(buf, dtype=np.uint8)
          data = data.reshape(num_images, rows, cols, 1)
          return data
  
imports: from pyspark import SparkContext
  from pyspark.sql import SparkSession
  from bigdl.dllib.nncontext import init_nncontext
  from bigdl.orca.data import SparkXShards
  from bigdl.orca.data.file import open_text, write_text
  from bigdl.orca.data.image.utils import chunks, dict_to_row, row_to_dict, encode_schema, decode_schema, SchemaField, FeatureType, DType, ndarray_dtype_to_dtype, decode_feature_type_ndarray, pa_fs
  from bigdl.orca.data.image.voc_dataset import VOCDatasets
  from bigdl.dllib.utils.common import get_node_and_core_number
  import os
  import numpy
  import random
  import io
  import math
  from bigdl.dllib.utils.log4Error import invalidInputError
  from numpy import ndarray, uint32
  from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple, Union, Any
label_desc: Use image node_id 2 for calling a global function with example usage: _extract_mnist_images(image_filepath) and returns: data