class_docstr: A table that can store Tensors or nested Tensors.
class_docstr_tok: ["A","table","that","can","store","Tensors","or","nested","Tensors","."]
docstr: Creates a table.
  
  Args:
    tensor_spec: A nest of TensorSpec representing each value that can be
      stored in the table.
    capacity: Maximum number of values the table can store.
    scope: Variable scope for the Table.
  
  Raises:
    ValueError: If the names in tensor_spec are empty or not unique.
docstr_tok: ["Creates","a","table",".","Args",":","tensor_spec",":","A","nest","of","TensorSpec","representing","each","value","that","can","be","stored","in","the","table",".","capacity",":","Maximum","number","of","values","the","table","can","store",".","scope",":","Variable","scope","for","the","Table",".","Raises",":","ValueError",":","If","the","names","in","tensor_spec","are","empty","or","not","unique","."]
code: def __init__(self, tensor_spec, capacity, scope="Table"):
      """Creates a table.
  
      Args:
        tensor_spec: A nest of TensorSpec representing each value that can be
          stored in the table.
        capacity: Maximum number of values the table can store.
        scope: Variable scope for the Table.
  
      Raises:
        ValueError: If the names in tensor_spec are empty or not unique.
      """
      super(Table, self).__init__(name=scope)
      self._tensor_spec = tensor_spec
      self._capacity = capacity
  
      def _create_unique_slot_name(spec):
          return tf.compat.v1.get_default_graph().unique_name(
              spec.name or "slot"
          )
  
      self._slots = tf.nest.map_structure(
          _create_unique_slot_name, self._tensor_spec
      )
  
      def _create_storage(spec, slot_name):
          """Create storage for a slot, track it."""
          shape = [self._capacity] + spec.shape.as_list()
          new_storage = common.create_variable(
              name=slot_name,
              initializer=tf.zeros(shape, dtype=spec.dtype),
              shape=None,
              dtype=spec.dtype,
              unique_name=False,
          )
          return new_storage
  
      with tf.compat.v1.variable_scope(scope):
          self._storage = tf.nest.map_structure(
              _create_storage, self._tensor_spec, self._slots
          )
  
      self._slot2storage_map = dict(
          zip(
              tf.nest.flatten(self._slots),
              tf.nest.flatten(self._storage),
          )
      )
  
file_path: agents/tf_agents/replay_buffers/table.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tf_agents.utils import common
label_desc: Use image node_id 1 to create a new Table object from inherited base classes: tf with example: obj = Table(tensor_spec, capacity, scope)