class_docstr: Collects samples for all policies and agents from a multi-agent env.
  
  This API is controlled by RolloutWorker objects to store all data
  generated by Environments and Policies/Models during rollout and
  postprocessing. It's purposes are to a) make data collection and
  SampleBatch/input_dict generation from this data faster, b) to unify
  the way we collect samples from environments and model (outputs), thereby
  allowing for possible user customizations, c) to allow for more complex
  inputs fed into different policies (e.g. multi-agent case with inter-agent
  communication channel).
class_docstr_tok: ["Collects","samples","for","all","policies","and","agents","from","a","multi-agent","env",".","This","API","is","controlled","by","RolloutWorker","objects","to","store","all","data","generated","by","Environments","and","Policies\/Models","during","rollout","and","postprocessing",".","It","'s","purposes","are","to","a",")","make","data","collection","and","SampleBatch\/input_dict","generation","from","this","data","faster",",","b",")","to","unify","the","way","we","collect","samples","from","environments","and","model","(","outputs",")",",","thereby","allowing","for","possible","user","customizations",",","c",")","to","allow","for","more","complex","inputs","fed","into","different","policies","(","e.g",".","multi-agent","case","with","inter-agent","communication","channel",")","."]
docstr: Postprocesses all agents' trajectories in a given episode.
  
  Generates (single-trajectory) SampleBatches for all Policies/Agents and
  calls Policy.postprocess_trajectory on each of these. Postprocessing
  may happens in-place, meaning any changes to the viewed data columns
  are directly reflected inside this collector's buffers.
  Also makes sure that additional (newly created) data columns are
  correctly added to the buffers.
  
  Args:
      episode: The Episode object for which
          to post-process data.
      is_done: Whether the given episode is actually terminated
          (all agents are terminated OR truncated). If True, the
          episode will no longer be used/continued and we may need to
          recycle/erase it internally. If a soft-horizon is hit, the
          episode will continue to be used and `is_done` should be set
          to False here.
      check_dones: Whether we need to check that all agents'
          trajectories have dones=True at the end.
      build: Whether to build a MultiAgentBatch from the given
          episode (and only that episode!) and return that
          MultiAgentBatch. Used for batch_mode=`complete_episodes`.
  
  Returns:
      Optional[MultiAgentBatch]: If `build` is True, the
          SampleBatch or MultiAgentBatch built from `episode` (either
          just from that episde or from the `_PolicyCollectorGroup`
          in the `episode.batch_builder` property).
docstr_tok: ["Postprocesses","all","agents","'","trajectories","in","a","given","episode",".","Generates","(","single-trajectory",")","SampleBatches","for","all","Policies\/Agents","and","calls","Policy.postprocess_trajectory","on","each","of","these",".","Postprocessing","may","happens","in-place",",","meaning","any","changes","to","the","viewed","data","columns","are","directly","reflected","inside","this","collector","'s","buffers",".","Also","makes","sure","that","additional","(","newly","created",")","data","columns","are","correctly","added","to","the","buffers",".","Args",":","episode",":","The","Episode","object","for","which","to","post-process","data",".","is_done",":","Whether","the","given","episode","is","actually","terminated","(","all","agents","are","terminated","OR","truncated",")",".","If","True",",","the","episode","will","no","longer","be","used\/continued","and","we","may","need","to","recycle\/erase","it","internally",".","If","a","soft-horizon","is","hit",",","the","episode","will","continue","to","be","used","and","`","is_done","`","should","be","set","to","False","here",".","check_dones",":","Whether","we","need","to","check","that","all","agents'","trajectories","have","dones=True","at","the","end",".","build",":","Whether","to","build","a","MultiAgentBatch","from","the","given","episode","(","and","only","that","episode","!",")","and","return","that","MultiAgentBatch",".","Used","for","batch_mode=","`","complete_episodes","`",".","Returns",":","Optional","[","MultiAgentBatch","]",":","If","`","build","`","is","True",",","the","SampleBatch","or","MultiAgentBatch","built","from","`","episode","`","(","either","just","from","that","episde","or","from","the","`","_PolicyCollectorGroup","`","in","the","`","episode.batch_builder","`","property",")","."]
code: def postprocess_episode(
      self,
      episode: Episode,
      is_done: bool = False,
      check_dones: bool = False,
      build: bool = False,
  ) -> Optional[MultiAgentBatch]:
      """Postprocesses all agents' trajectories in a given episode.
  
      Generates (single-trajectory) SampleBatches for all Policies/Agents and
      calls Policy.postprocess_trajectory on each of these. Postprocessing
      may happens in-place, meaning any changes to the viewed data columns
      are directly reflected inside this collector's buffers.
      Also makes sure that additional (newly created) data columns are
      correctly added to the buffers.
  
      Args:
          episode: The Episode object for which
              to post-process data.
          is_done: Whether the given episode is actually terminated
              (all agents are terminated OR truncated). If True, the
              episode will no longer be used/continued and we may need to
              recycle/erase it internally. If a soft-horizon is hit, the
              episode will continue to be used and `is_done` should be set
              to False here.
          check_dones: Whether we need to check that all agents'
              trajectories have dones=True at the end.
          build: Whether to build a MultiAgentBatch from the given
              episode (and only that episode!) and return that
              MultiAgentBatch. Used for batch_mode=`complete_episodes`.
  
      Returns:
          Optional[MultiAgentBatch]: If `build` is True, the
              SampleBatch or MultiAgentBatch built from `episode` (either
              just from that episde or from the `_PolicyCollectorGroup`
              in the `episode.batch_builder` property).
      """
      raise NotImplementedError
  
file_path: ray/rllib/evaluation/collectors/sample_collector.py
imports: import logging
  from abc import ABCMeta, abstractmethod
  from typing import TYPE_CHECKING, Dict, List, Optional, Union
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.policy.policy_map import PolicyMap
  from ray.rllib.policy.sample_batch import MultiAgentBatch, SampleBatch
  from ray.rllib.utils.annotations import PublicAPI
  from ray.rllib.utils.typing import AgentID, EnvID, EpisodeID, PolicyID, TensorType
label_desc: Use image node_id 8 for calling the SampleCollector obj's underlying member method code with example usage: obj.postprocess_episode(episode, is_done, check_dones, build) without return types