class_docstr: Adapter for Python generators.
code: def _set_tf_output_signature(self):
      from keras.utils.module_utils import tensorflow as tf
  
      data, generator = peek_and_restore(self.generator)
      self.generator = generator
  
      def get_tensor_spec(x):
          shape = x.shape
          if len(shape) < 1:
              raise ValueError(
                  "When passing a Python generator to a Keras model, "
                  "the arrays returned by the generator "
                  "must be at least rank 1. Received: "
                  f"{x} of rank {len(x.shape)}"
              )
          shape = list(shape)
          shape[
              0
          ] = None  # The batch size is not guaranteed to be static.
          if isinstance(x, tf.RaggedTensor):
              return tf.RaggedTensorSpec(
                  shape=shape, dtype=x.dtype.name
              )
          if isinstance(x, tf.SparseTensor) or is_scipy_sparse(x):
              return tf.SparseTensorSpec(
                  shape=shape, dtype=x.dtype.name
              )
          else:
              return tf.TensorSpec(shape=shape, dtype=x.dtype.name)
  
      self._output_signature = tree.map_structure(get_tensor_spec, data)
  
file_path: keras/keras/trainers/data_adapters/generator_data_adapter.py
imports: import itertools
  import numpy
  import tree
  from keras.trainers.data_adapters.data_adapter import DataAdapter
label_desc: Use image node_id 2 for calling the GeneratorDataAdapter obj's underlying member method code with example usage: obj._set_tf_output_signature() and returns: tf, tf, tf