class_docstr: An in-progress episode.
  
  Compared to EpisodeBatch, this datatype does less checking, only
  contains one episodes, and uses lists instead of numpy arrays to make
  stepping faster.
  
  Args:
      env (Environment): The environment the trajectory is being collected
          in.
      initial_observation (np.ndarray): The first observation. If None, the
          environment will be reset to generate this observation.
      episode_info (dict[str, np.ndarray]): Info for this episode.
  
  Raises:
      ValueError: if either initial_observation and episode_info is passed in
          but not the other. Either both or neither should be passed in.
docstr: Convert this in-progress episode into a EpisodeBatch.
  
  Returns:
      EpisodeBatch: This episode as a batch.
  
  Raises:
      AssertionError: If this episode contains no time steps.
docstr_tok: ["Convert","this","in-progress","episode","into","a","EpisodeBatch",".","Returns",":","EpisodeBatch",":","This","episode","as","a","batch",".","Raises",":","AssertionError",":","If","this","episode","contains","no","time","steps","."]
code: def to_batch(self):
      """Convert this in-progress episode into a EpisodeBatch.
  
      Returns:
          EpisodeBatch: This episode as a batch.
  
      Raises:
          AssertionError: If this episode contains no time steps.
  
      """
      assert len(self.rewards) > 0
      env_infos = dict(self.env_infos)
      agent_infos = dict(self.agent_infos)
      episode_infos = dict(self.episode_info)
      for k, v in env_infos.items():
          env_infos[k] = np.asarray(v)
      for k, v in agent_infos.items():
          agent_infos[k] = np.asarray(v)
      for k, v in episode_infos.items():
          episode_infos[k] = np.asarray([v])
      return EpisodeBatch(
          episode_infos=episode_infos,
          env_spec=self.env.spec,
          observations=np.asarray(self.observations[:-1]),
          last_observations=np.asarray([self.last_obs]),
          actions=np.asarray(self.actions),
          rewards=np.asarray(self.rewards),
          step_types=np.asarray(self.step_types, dtype=StepType),
          env_infos=env_infos,
          agent_infos=agent_infos,
          lengths=np.asarray([len(self.rewards)], dtype="l"),
      )
  
imports: import collections
  import numpy
  from garage import EpisodeBatch, StepType
label_desc: Use image node_id 3 for calling the InProgressEpisode obj's underlying member method code with example usage: obj.to_batch() and returns: EpisodeBatch