class_docstr: A replay buffer that stores and can sample whole episodes.
  
  This buffer only stores valid steps, and doesn't require paths to
  have a maximum length.
  
  Args:
      capacity_in_transitions (int): Total memory allocated for the buffer.
      env_spec (EnvSpec): Environment specification.
class_docstr_tok: ["A","replay","buffer","that","stores","and","can","sample","whole","episodes",".","This","buffer","only","stores","valid","steps",",","and","does","n't","require","paths","to","have","a","maximum","length",".","Args",":","capacity_in_transitions","(","int",")",":","Total","memory","allocated","for","the","buffer",".","env_spec","(","EnvSpec",")",":","Environment","specification","."]
docstr: Add a EpisodeBatch to the buffer.
  
  Args:
      episodes (EpisodeBatch): Episodes to add.
docstr_tok: ["Add","a","EpisodeBatch","to","the","buffer",".","Args",":","episodes","(","EpisodeBatch",")",":","Episodes","to","add","."]
code: def add_episode_batch(self, episodes):
      """Add a EpisodeBatch to the buffer.
  
      Args:
          episodes (EpisodeBatch): Episodes to add.
  
      """
      if self._env_spec is None:
          self._env_spec = episodes.env_spec
      env_spec = episodes.env_spec
      obs_space = env_spec.observation_space
      for eps in episodes.split():
          terminals = np.array(
              [
                  step_type == StepType.TERMINAL
                  for step_type in eps.step_types
              ],
              dtype=bool,
          )
          path = {
              "observations": obs_space.flatten_n(eps.observations),
              "next_observations": obs_space.flatten_n(
                  eps.next_observations
              ),
              "actions": env_spec.action_space.flatten_n(eps.actions),
              "rewards": eps.rewards.reshape(-1, 1),
              "terminals": terminals.reshape(-1, 1),
          }
          self.add_path(path)
  
file_path: garage/src/garage/replay_buffer/path_buffer.py
imports: import collections
  import numpy
  from garage import StepType, TimeStepBatch
label_desc: Use image node_id 2 for calling the PathBuffer obj's underlying member method code with example usage: obj.add_episode_batch(episodes) without return types