class_docstr: Base class for memories organized as a queue / circular buffer.
  
  Args:
      capacity (int > 0): Memory capacity
          (<span style="color:#00C000"><b>default</b></span>: minimum capacity).
      device (string): Device name
          (<span style="color:#00C000"><b>default</b></span>: CPU:0).
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
      values_spec (specification): <span style="color:#0000C0"><b>internal use</b></span>.
      min_capacity (int >= 0): <span style="color:#0000C0"><b>internal use</b></span>.
class_docstr_tok: ["Base","class","for","memories","organized","as","a","queue","\/","circular","buffer",".","Args",":","capacity","(","int",">","0",")",":","Memory","capacity","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","minimum","capacity",")",".","device","(","string",")",":","Device","name","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","CPU:0",")",".","name","(","string",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","values_spec","(","specification",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">",".","min_capacity","(","int",">","=","0",")",":","<","span","style=","''","color",":","#","0000C0","''",">","<","b",">","internal","use","<","\/b",">","<","\/span",">","."]
code: def reset(self):
      zero = tf_util.constant(value=0, dtype="int")
      one = tf_util.constant(value=1, dtype="int")
      three = tf_util.constant(value=3, dtype="int")
      capacity = tf_util.constant(value=self.capacity, dtype="int")
      last_index = tf.math.mod(x=(self.buffer_index - one), y=capacity)
  
      def correct_terminal():
          # Replace last observation terminal marker with abort terminal
          dependencies = list()
          two = tf_util.constant(value=2, dtype="int", shape=(1,))
          updates = tf.expand_dims(
              input=last_index, axis=0
          )  # updates for below
          indices = tf.expand_dims(input=updates, axis=1)
          value = tf.tensor_scatter_nd_update(
              tensor=self.buffers["terminal"],
              indices=indices,
              updates=two,
          )
          dependencies.append(
              self.buffers["terminal"].assign(value=value)
          )
          # sparse_delta = tf.IndexedSlices(values=two, indices=last_index)
          # dependencies.append(self.buffers['terminal'].scatter_update(sparse_delta=sparse_delta))
          indices = tf.expand_dims(
              input=tf.expand_dims(
                  input=(self.episode_count + one), axis=0
              ),
              axis=1,
          )
          value = tf.tensor_scatter_nd_update(
              tensor=self.terminal_indices,
              indices=indices,
              updates=updates,
          )
          dependencies.append(self.terminal_indices.assign(value=value))
          # sparse_delta = tf.IndexedSlices(values=last_index, indices=(self.episode_count + one))
          # dependencies.append(self.terminal_indices.scatter_update(sparse_delta=sparse_delta))
          with tf.control_dependencies(control_inputs=dependencies):
              return self.episode_count.assign_add(
                  delta=one, read_value=False
              )
  
      last_terminal = tf.gather(
          params=self.buffers["terminal"], indices=last_index
      )
      is_incorrect = tf.math.equal(x=last_terminal, y=three)
      corrected = tf.cond(
          pred=is_incorrect, true_fn=correct_terminal, false_fn=tf.no_op
      )
  
      with tf.control_dependencies(control_inputs=(corrected,)):
          assertions = [corrected]
          if self.config.create_tf_assertions:
              # general check: all terminal indices true
              assertions.append(
                  tf.debugging.assert_equal(
                      x=tf.reduce_all(
                          input_tensor=tf.gather(
                              params=tf.math.greater(
                                  x=self.buffers["terminal"], y=zero
                              ),
                              indices=self.terminal_indices[
                                  : self.episode_count + one
                              ],
                          )
                      ),
                      y=tf_util.constant(value=True, dtype="bool"),
                      message="Memory consistency check.",
                  )
              )
              # general check: only terminal indices true
              assertions.append(
                  tf.debugging.assert_equal(
                      x=tf.math.count_nonzero(
                          input=self.buffers["terminal"],
                          dtype=tf_util.get_dtype(type="int"),
                      ),
                      y=(self.episode_count + one),
                      message="Memory consistency check.",
                  )
              )
  
      with tf.control_dependencies(control_inputs=assertions):
          return one < zero
  
file_path: tensorforce/tensorforce/core/memories/queue.py
imports: import numpy
  import tensorflow
  from tensorforce import TensorforceError, util
  from tensorforce.core import TensorDict, TensorSpec, tf_function, tf_util, VariableDict
  from tensorforce.core.memories import Memory
label_desc: Use image node_id 3 for calling the Queue obj's underlying member method code with example usage: obj.reset() and returns: unknown, self