class_docstr: Base class for tensor generator.
  
  Generator generates tf.Tensor, tf.sparse.SparseTensor, or
  tf.RaggedTensor based on the input spec. The spec is one of the
  tf.TensorSpec, tf.SparseTensorSpec or tf.RaggedTensorSpec.
docstr: Create a new Generator.
  
  This must be called by the constructors of subclasses.
  
  Args:
    spec: A tf.TensorSpec, tf.SparseTensorSpec or tf.RaggedTensorSpec that
      describes the tensor generated by this generator.
  
  Raises:
    TypeError: If spec is not one of the tf.TensorSpec, tf.SparseTensorSpec
      or tf.RaggedTensorSpec.
code: def __init__(self, spec):
      """Create a new Generator.
  
      This must be called by the constructors of subclasses.
  
      Args:
        spec: A tf.TensorSpec, tf.SparseTensorSpec or tf.RaggedTensorSpec that
          describes the tensor generated by this generator.
  
      Raises:
        TypeError: If spec is not one of the tf.TensorSpec, tf.SparseTensorSpec
          or tf.RaggedTensorSpec.
      """
      if not isinstance(spec, Generator._SUPPORTED_SPEC):
          raise TypeError(
              "Generator can only accept spec in one of the "
              f"{Generator._SUPPORTED_SPEC} types but found {spec}."
          )
      self._spec = spec
  
file_path: io/tests/test_atds_avro/utils/generator/generator_base.py
imports: import abc
  import hashlib
  import tensorflow
  from tests.test_atds_avro.utils.hash_util import int_to_bytes
label_desc: Use image node_id 1 to create a new Generator object  with example: obj = Generator(spec)