code: def mnist_generator(
      shuffle: bool = False,
      batch_size: int = 64,
      train: bool = True,
      n_samples: int = None,
      model=None,
  ) -> t.Generator:
      """Generate an MNIST dataset.
  
      Parameters
      ----------
      batch_size: int, optional
          how many samples per batch to load
      train : bool, default : True
          Train or Test dataset
      n_samples : int, optional
          Number of samples to load.
      shuffle : bool , default : False
          whether to shuffle the data or not.
      model : MockModel, optional
          Model to use for predictions
  
      Returns
      -------
      :obj:`t.Generator`
      """
      images, labels = load_mnist_data(
          train, n_samples=n_samples, shuffle=shuffle
      )
  
      for i in range(0, len(images), batch_size):
          return_dict = {
              "images": images[i : (i + batch_size) :],
              "labels": labels[i : (i + batch_size) :],
          }
          if model is not None:
              return_dict.update(
                  {"predictions": model(return_dict["images"])}
              )
  
          # deepchecks expects images to be in the range [0, 255]
          return_dict["images"] = return_dict["images"] * 255.0
          yield return_dict
  
file_path: deepchecks/deepchecks/vision/datasets/classification/mnist_tensorflow.py
imports: import logging
  import pathlib
  import pickle
  import typing
  import numpy
  from deepchecks.vision.utils.test_utils import hash_image
  from deepchecks.vision.vision_data import VisionData
label_desc: Use image node_id 2 for calling a global function with example usage: mnist_generator(shuffle, batch_size, train, n_samples, model) without return types