class_docstr: This buffer implements reservoir sampling.
  
  The algorithm has been described by Jeffrey S. Vitter in "Random sampling
  with a reservoir".
class_docstr_tok: ["This","buffer","implements","reservoir","sampling",".","The","algorithm","has","been","described","by","Jeffrey","S.","Vitter","in","``","Random","sampling","with","a","reservoir","''","."]
docstr: Add a SampleBatch of experiences to self._storage.
  
  An item consists of either one or more timesteps, a sequence or an
  episode. Differs from add() in that it does not consider the storage
  unit or type of batch and simply stores it.
  
  Args:
      item: The batch to be added.
      ``**kwargs``: Forward compatibility kwargs.
docstr_tok: ["Add","a","SampleBatch","of","experiences","to","self._storage",".","An","item","consists","of","either","one","or","more","timesteps",",","a","sequence","or","an","episode",".","Differs","from","add","(",")","in","that","it","does","not","consider","the","storage","unit","or","type","of","batch","and","simply","stores","it",".","Args",":","item",":","The","batch","to","be","added",".","``","*","*","kwargs","``",":","Forward","compatibility","kwargs","."]
code: def _add_single_batch(self, item: SampleBatchType, **kwargs) -> None:
      """Add a SampleBatch of experiences to self._storage.
  
      An item consists of either one or more timesteps, a sequence or an
      episode. Differs from add() in that it does not consider the storage
      unit or type of batch and simply stores it.
  
      Args:
          item: The batch to be added.
          ``**kwargs``: Forward compatibility kwargs.
      """
      self._num_timesteps_added += item.count
      self._num_timesteps_added_wrap += item.count
  
      # Update add counts.
      self._num_add_calls += 1
      # Update our timesteps counts.
  
      if self._num_timesteps_added < self.capacity:
          self._storage.append(item)
          self._est_size_bytes += item.size_bytes()
      else:
          # Eviction of older samples has already started (buffer is "full")
          self._eviction_started = True
          idx = random.randint(0, self._num_add_calls - 1)
          if idx < len(self._storage):
              self._num_evicted += 1
              self._evicted_hit_stats.push(self._hit_count[idx])
              self._hit_count[idx] = 0
              # This is a bit of a hack: ReplayBuffer always inserts at
              # self._next_idx
              self._next_idx = idx
              self._evicted_hit_stats.push(self._hit_count[idx])
              self._hit_count[idx] = 0
  
              item_to_be_removed = self._storage[idx]
              self._est_size_bytes -= item_to_be_removed.size_bytes()
              self._storage[idx] = item
              self._est_size_bytes += item.size_bytes()
  
              assert item.count > 0, item
              warn_replay_capacity(
                  item=item, num_items=self.capacity / item.count
              )
  
file_path: ray/rllib/utils/replay_buffers/reservoir_replay_buffer.py
imports: from typing import Any, Dict
  import random
  import ray
  import psutil
  from ray.rllib.utils.annotations import ExperimentalAPI, override
  from ray.rllib.utils.replay_buffers.replay_buffer import ReplayBuffer, warn_replay_capacity
  from ray.rllib.utils.typing import SampleBatchType
label_desc: Use image node_id 2 for calling the ReservoirReplayBuffer obj's underlying member method code with example usage: obj._add_single_batch(item) without return types