class_docstr: Base of SparseTensorGenerator that generates tf.sparse.SparseTensor.
class_docstr_tok: ["Base","of","SparseTensorGenerator","that","generates","tf.sparse.SparseTensor","."]
docstr: Create a new SparseTensorGeneratorBase.
  
  This must be called by the constructors of subclasses e.g.
  IntSparseTensorGenerator, FloatSparseTensorGenerator, etc.
  
  Args:
    spec: A tf.SparseTensorSpec that describes the output tensor.
    num_values: A value distribution or an int specifying number of non-zero values in the sparse tensor.
  
  Raises:
    TypeError: If spec is not tf.SparseTensorSpec.
docstr_tok: ["Create","a","new","SparseTensorGeneratorBase",".","This","must","be","called","by","the","constructors","of","subclasses","e.g",".","IntSparseTensorGenerator",",","FloatSparseTensorGenerator",",","etc",".","Args",":","spec",":","A","tf.SparseTensorSpec","that","describes","the","output","tensor",".","num_values",":","A","value","distribution","or","an","int","specifying","number","of","non-zero","values","in","the","sparse","tensor",".","Raises",":","TypeError",":","If","spec","is","not","tf.SparseTensorSpec","."]
code: def __init__(self, spec, num_values):
      """Create a new SparseTensorGeneratorBase.
  
      This must be called by the constructors of subclasses e.g.
      IntSparseTensorGenerator, FloatSparseTensorGenerator, etc.
  
      Args:
        spec: A tf.SparseTensorSpec that describes the output tensor.
        num_values: A value distribution or an int specifying number of non-zero values in the sparse tensor.
  
      Raises:
        TypeError: If spec is not tf.SparseTensorSpec.
      """
      super().__init__(spec)
  
      if not isinstance(spec, tf.SparseTensorSpec):
          raise TypeError(
              "Input spec must be a tf.SparseTensorSpec in SparseTensorGenerator "
              f"but found {spec}"
          )
  
      if not isinstance(num_values, (int, ValueDistribution)):
          raise TypeError(
              f"num_values must be an int or ValueDistribution but found {num_values}"
          )
  
      self._value_dist = None
      if isinstance(num_values, int):
          self._num_values = num_values
      elif num_values == ValueDistribution.SINGLE_VALUE:
          self._num_values = 1
      else:
          self._value_dist = num_values
  
imports: import enum
  import random
  import hashlib
  import numpy
  import tensorflow
  from tests.test_atds_avro.utils.generator.generator_base import Generator
  from tests.test_atds_avro.utils.hash_util import int_to_bytes
label_desc: Use image node_id 1 to create a new SparseTensorGeneratorBase object from inherited base classes: Generator with example: obj = SparseTensorGeneratorBase(spec, num_values)