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: Return the hasehd code of this Generator in hex str.
  
  The hashed code helps create the data source cache path on disk.
  
  Returns:
    A hashed hex str of this Generator.
code: def hash_code(self):
      """Return the hasehd code of this Generator in hex str.
  
      The hashed code helps create the data source cache path on disk.
  
      Returns:
        A hashed hex str of this Generator.
      """
      m = hashlib.sha256()
  
      # Step 1: hash class name
      classname = self.get_generator_cls().__name__
      m.update(classname.encode())
  
      # Step 2: hash input spec using default hash function in tf.TypeSpec
      if isinstance(self.spec, tf.TensorSpec):
          m.update(tf.TensorSpec.__name__.encode())
      elif isinstance(self.spec, tf.SparseTensorSpec):
          m.update(tf.SparseTensorSpec.__name__.encode())
      elif isinstance(self.spec, tf.RaggedTensorSpec):
          m.update(tf.RaggedTensorSpec.__name__.encode())
          m.update(b"ragged_rank")
          m.update(int_to_bytes(self.spec.ragged_rank))
          m.update(b"row_splits_dtype")
          m.update(int_to_bytes(hash(self.spec.row_splits_dtype)))
          m.update(b"flat_values_spec")
          if self.spec.flat_values_spec:
              m.update(int_to_bytes(hash(self.spec.flat_values_spec)))
      else:
          raise TypeError(
              f"Generator.spec is not one of {Generator._SUPPORTED_SPEC}."
          )
  
      self._hash_shape(m, self.spec.shape)
      self._hash_dtype(m, self.spec.dtype)
  
      # Step 3" return hashed hex str.
      return m.hexdigest()
  
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 5 for calling the Generator obj's underlying member method code with example usage: obj.hash_code() and returns: m