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: Initializes a SampleCollector instance.
  
  Args:
      policy_map: Maps policy ids to policy instances.
      clip_rewards (Union[bool, float]): Whether to clip rewards before
          postprocessing (at +/-1.0) or the actual value to +/- clip.
      callbacks: RLlib callbacks.
      multiple_episodes_in_batch: Whether it's allowed to pack
          multiple episodes into the same built batch.
      rollout_fragment_length: The
docstr_tok: ["Initializes","a","SampleCollector","instance",".","Args",":","policy_map",":","Maps","policy","ids","to","policy","instances",".","clip_rewards","(","Union","[","bool",",","float","]",")",":","Whether","to","clip","rewards","before","postprocessing","(","at","+\/-1.0",")","or","the","actual","value","to","+\/-","clip",".","callbacks",":","RLlib","callbacks",".","multiple_episodes_in_batch",":","Whether","it","'s","allowed","to","pack","multiple","episodes","into","the","same","built","batch",".","rollout_fragment_length",":","The"]
code: def __init__(
      self,
      policy_map: PolicyMap,
      clip_rewards: Union[bool, float],
      callbacks: "DefaultCallbacks",
      multiple_episodes_in_batch: bool = True,
      rollout_fragment_length: int = 200,
      count_steps_by: str = "env_steps",
  ):
      """Initializes a SampleCollector instance.
  
      Args:
          policy_map: Maps policy ids to policy instances.
          clip_rewards (Union[bool, float]): Whether to clip rewards before
              postprocessing (at +/-1.0) or the actual value to +/- clip.
          callbacks: RLlib callbacks.
          multiple_episodes_in_batch: Whether it's allowed to pack
              multiple episodes into the same built batch.
          rollout_fragment_length: The
  
      """
  
      self.policy_map = policy_map
      self.clip_rewards = clip_rewards
      self.callbacks = callbacks
      self.multiple_episodes_in_batch = multiple_episodes_in_batch
      self.rollout_fragment_length = rollout_fragment_length
      self.count_steps_by = count_steps_by
  
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 1 to create a new SampleCollector object  with example: obj = SampleCollector(policy_map, clip_rewards, callbacks, multiple_episodes_in_batch, rollout_fragment_length, count_steps_by)