class_docstr: A class to store nested objects in a collection of numpy arrays.
  
  If a data_spec of `{'foo': ArraySpec(shape=(4,), dtype=np.uint8), 'bar':
  ArraySpec(shape=(3, 7), dtype=np.float32)}` were used, then this would create
  two arrays, one for the 'foo' key and one for the 'bar' key. The .get and
  .set methods would return/take Python dictionaries, but break down the
  component arrays before storing them.
docstr: Creates a NumpyStorage object.
  
  Args:
    data_spec: An ArraySpec or a list/tuple/nest of ArraySpecs describing a
      single item that can be stored in this table.
    capacity: The maximum number of items that can be stored in the buffer.
  
  Raises:
    ValueError: If data_spec is not an instance or nest of ArraySpecs.
docstr_tok: ["Creates","a","NumpyStorage","object",".","Args",":","data_spec",":","An","ArraySpec","or","a","list\/tuple\/nest","of","ArraySpecs","describing","a","single","item","that","can","be","stored","in","this","table",".","capacity",":","The","maximum","number","of","items","that","can","be","stored","in","the","buffer",".","Raises",":","ValueError",":","If","data_spec","is","not","an","instance","or","nest","of","ArraySpecs","."]
code: def __init__(self, data_spec, capacity):
      """Creates a NumpyStorage object.
  
      Args:
        data_spec: An ArraySpec or a list/tuple/nest of ArraySpecs describing a
          single item that can be stored in this table.
        capacity: The maximum number of items that can be stored in the buffer.
  
      Raises:
        ValueError: If data_spec is not an instance or nest of ArraySpecs.
      """
      self._capacity = capacity
      if not all(
          [
              isinstance(spec, array_spec.ArraySpec)
              for spec in tf.nest.flatten(data_spec)
          ]
      ):
          raise ValueError(
              "The data_spec parameter must be an instance or nest of "
              "array_spec.ArraySpec. Got: {}".format(data_spec)
          )
      self._data_spec = data_spec
      self._flat_specs = tf.nest.flatten(data_spec)
      self._np_state = NumpyState()
  
      self._buf_names = data_structures.NoDependency([])
      for idx in range(len(self._flat_specs)):
          self._buf_names.append("buffer{}".format(idx))
          # Set each buffer to a sentinel value (real buffers will never be
          # scalars) rather than a real value so that if they are restored from
          # checkpoint, we don't end up double-initializing. We don't leave them
          # as unset because setting them to a numpy value tells the checkpointer
          # this will be a checkpointed attribute and it creates TF ops for it.
          setattr(self._np_state, self._buf_names[idx], np.int64(0))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import io
  import numpy
  import tensorflow
  from tf_agents.specs import array_spec
  from tensorflow.python.trackable import base
  from tensorflow.python.trackable import data_structures
label_desc: Use image node_id 1 to create a new NumpyStorage object from inherited base classes: tf with example: obj = NumpyStorage(data_spec, capacity)