code: def image_data_generator(
      framework,
      get_default_mnist_subset,
      image_iterator,
      default_batch_size,
  ):
      def _image_data_generator(**kwargs):
          (x_train_mnist, y_train_mnist), (
              _,
              _,
          ) = get_default_mnist_subset
          image_it = image_iterator()
          data_generator = None
  
          if framework == "keras" or framework == "kerastf":
              data_generator = KerasDataGenerator(
                  iterator=image_it,
                  size=x_train_mnist.shape[0],
                  batch_size=default_batch_size,
              )
  
          if framework in ["tensorflow1", "tensorflow2v1"]:
              data_generator = TensorFlowDataGenerator(
                  sess=kwargs["sess"],
                  iterator=image_it,
                  iterator_type="initializable",
                  iterator_arg={},
                  size=x_train_mnist.shape[0],
                  batch_size=default_batch_size,
              )
  
          if framework == "tensorflow2":
              data_generator = TensorFlowV2DataGenerator(
                  iterator=image_it,
                  size=x_train_mnist.shape[0],
                  batch_size=default_batch_size,
              )
  
          if framework in ["pytorch", "huggingface"]:
              data_generator = PyTorchDataGenerator(
                  iterator=image_it,
                  size=x_train_mnist.shape[0],
                  batch_size=default_batch_size,
              )
  
          if framework == "mxnet":
              data_generator = MXDataGenerator(
                  iterator=image_it,
                  size=x_train_mnist.shape[0],
                  batch_size=default_batch_size,
              )
  
          return data_generator
  
      return _image_data_generator
  
imports: import importlib
  import json
  import logging
  import os
  import shutil
  import tempfile
  from typing import Dict, List, TYPE_CHECKING, Union
  import warnings
  import numpy
  import pytest
  import requests
  from art.data_generators import KerasDataGenerator, MXDataGenerator, PyTorchDataGenerator, TensorFlowDataGenerator, TensorFlowV2DataGenerator
  from art.defences.preprocessor import FeatureSqueezing, JpegCompression, SpatialSmoothing
  from art.estimators.classification import KerasClassifier
  from tests.utils import ARTTestFixtureNotImplemented, get_attack_classifier_pt, get_image_classifier_kr, get_image_classifier_kr_functional, get_image_classifier_kr_tf, get_image_classifier_kr_tf_functional, get_image_classifier_kr_tf_with_wildcard, get_image_classifier_mxnet_custom_ini, get_image_classifier_pt, get_image_classifier_pt_functional, get_image_classifier_tf, get_image_classifier_hf, get_image_gan_tf_v2, get_image_generator_tf_v2, get_tabular_classifier_kr, get_tabular_classifier_pt, get_tabular_classifier_scikit_list, get_tabular_classifier_tf, load_dataset, master_seed
label_desc: Use image node_id 8 for calling a global function with example usage: image_data_generator(framework, get_default_mnist_subset, image_iterator, default_batch_size) and returns: _image_data_generator, data_generator