code: def example_generator(x, y, sample_weight=None, batch_size=32):
      def make():
          for i in range(math.ceil(len(x) / batch_size)):
              low = i * batch_size
              high = min(low + batch_size, len(x))
              batch_x = x[low:high]
              batch_y = y[low:high]
              if sample_weight is not None:
                  yield batch_x, batch_y, sample_weight[low:high]
              else:
                  yield batch_x, batch_y
  
      return make
  
file_path: keras/keras/trainers/data_adapters/generator_data_adapter_test.py
imports: import math
  import numpy
  import scipy
  import tensorflow
  from absl.testing import parameterized
  from keras import testing
  from keras.trainers.data_adapters import generator_data_adapter
label_desc: Use image node_id 1 for calling a global function with example usage: example_generator(x, y, sample_weight, batch_size) and returns: make