class_docstr: A prioritized replay buffer shard for multiagent setups.
  
  This buffer is meant to be run in parallel to distribute experiences
  across `num_shards` shards. Unlike simpler buffers, it holds a set of
  buffers - one for each policy ID.
class_docstr_tok: ["A","prioritized","replay","buffer","shard","for","multiagent","setups",".","This","buffer","is","meant","to","be","run","in","parallel","to","distribute","experiences","across","`","num_shards","`","shards",".","Unlike","simpler","buffers",",","it","holds","a","set","of","buffers","-","one","for","each","policy","ID","."]
docstr: Initializes a MultiAgentReplayBuffer instance.
  
  Args:
      capacity: The capacity of the buffer, measured in `storage_unit`.
      storage_unit: Either 'timesteps', 'sequences' or
          'episodes'. Specifies how experiences are stored. If they
          are stored in episodes, replay_sequence_length is ignored.
          If they are stored in episodes, replay_sequence_length is
          ignored.
      num_shards: The number of buffer shards that exist in total
          (including this one).
      replay_mode: One of "independent" or "lockstep". Determines,
          whether batches are sampled independently or to an equal
          amount.
      replay_sequence_override: If True, ignore sequences found in incoming
          batches, slicing them into sequences as specified by
          `replay_sequence_length` and `replay_sequence_burn_in`. This only has
          an effect if storage_unit is `sequences`.
      replay_sequence_length: The sequence length (T) of a single
          sample. If > 1, we will sample B x T from this buffer.
      replay_burn_in: The burn-in length in case
          `replay_sequence_length` > 0. This is the number of timesteps
          each sequence overlaps with the previous one to generate a
          better internal state (=state after the burn-in), instead of
          starting from 0.0 each RNN rollout.
      replay_zero_init_states: Whether the initial states in the
          buffer (if replay_sequence_length > 0) are alwayas 0.0 or
          should be updated with the previous train_batch state outputs.
      underlying_buffer_config: A config that contains all necessary
          constructor arguments and arguments for methods to call on
          the underlying buffers. This replaces the standard behaviour
          of the underlying PrioritizedReplayBuffer. The config
          follows the conventions of the general
          replay_buffer_config. kwargs for subsequent calls of methods
          may also be included. Example:
          "replay_buffer_config": {"type": PrioritizedReplayBuffer,
          "capacity": 10, "storage_unit": "timesteps",
          prioritized_replay_alpha: 0.5, prioritized_replay_beta: 0.5,
          prioritized_replay_eps: 0.5}
      prioritized_replay_alpha: Alpha parameter for a prioritized
          replay buffer. Use 0.0 for no prioritization.
      prioritized_replay_beta: Beta parameter for a prioritized
          replay buffer.
      prioritized_replay_eps: Epsilon parameter for a prioritized
          replay buffer.
      ``**kwargs``: Forward compatibility kwargs.
docstr_tok: ["Initializes","a","MultiAgentReplayBuffer","instance",".","Args",":","capacity",":","The","capacity","of","the","buffer",",","measured","in","`","storage_unit","`",".","storage_unit",":","Either","'timesteps","'",",","'sequences","'","or","'episodes","'",".","Specifies","how","experiences","are","stored",".","If","they","are","stored","in","episodes",",","replay_sequence_length","is","ignored",".","If","they","are","stored","in","episodes",",","replay_sequence_length","is","ignored",".","num_shards",":","The","number","of","buffer","shards","that","exist","in","total","(","including","this","one",")",".","replay_mode",":","One","of","``","independent","''","or","``","lockstep","''",".","Determines",",","whether","batches","are","sampled","independently","or","to","an","equal","amount",".","replay_sequence_override",":","If","True",",","ignore","sequences","found","in","incoming","batches",",","slicing","them","into","sequences","as","specified","by","`","replay_sequence_length","`","and","`","replay_sequence_burn_in","`",".","This","only","has","an","effect","if","storage_unit","is","`","sequences","`",".","replay_sequence_length",":","The","sequence","length","(","T",")","of","a","single","sample",".","If",">","1",",","we","will","sample","B","x","T","from","this","buffer",".","replay_burn_in",":","The","burn-in","length","in","case","`","replay_sequence_length","`",">","0",".","This","is","the","number","of","timesteps","each","sequence","overlaps","with","the","previous","one","to","generate","a","better","internal","state","(","=state","after","the","burn-in",")",",","instead","of","starting","from","0.0","each","RNN","rollout",".","replay_zero_init_states",":","Whether","the","initial","states","in","the","buffer","(","if","replay_sequence_length",">","0",")","are","alwayas","0.0","or","should","be","updated","with","the","previous","train_batch","state","outputs",".","underlying_buffer_config",":","A","config","that","contains","all","necessary","constructor","arguments","and","arguments","for","methods","to","call","on","the","underlying","buffers",".","This","replaces","the","standard","behaviour","of","the","underlying","PrioritizedReplayBuffer",".","The","config","follows","the","conventions","of","the","general","replay_buffer_config",".","kwargs","for","subsequent","calls","of","methods","may","also","be","included",".","Example",":","``","replay_buffer_config","''",":","{","``","type","''",":","PrioritizedReplayBuffer",",","``","capacity","''",":","10",",","``","storage_unit","''",":","``","timesteps","''",",","prioritized_replay_alpha",":","0.5",",","prioritized_replay_beta",":","0.5",",","prioritized_replay_eps",":","0.5","}","prioritized_replay_alpha",":","Alpha","parameter","for","a","prioritized","replay","buffer",".","Use","0.0","for","no","prioritization",".","prioritized_replay_beta",":","Beta","parameter","for","a","prioritized","replay","buffer",".","prioritized_replay_eps",":","Epsilon","parameter","for","a","prioritized","replay","buffer",".","``","*","*","kwargs","``",":","Forward","compatibility","kwargs","."]
code: def __init__(
      self,
      capacity: int = 10000,
      storage_unit: str = "timesteps",
      num_shards: int = 1,
      replay_mode: str = "independent",
      replay_sequence_override: bool = True,
      replay_sequence_length: int = 1,
      replay_burn_in: int = 0,
      replay_zero_init_states: bool = True,
      underlying_buffer_config: dict = None,
      prioritized_replay_alpha: float = 0.6,
      prioritized_replay_beta: float = 0.4,
      prioritized_replay_eps: float = 1e-6,
      **kwargs,
  ):
      """Initializes a MultiAgentReplayBuffer instance.
  
      Args:
          capacity: The capacity of the buffer, measured in `storage_unit`.
          storage_unit: Either 'timesteps', 'sequences' or
              'episodes'. Specifies how experiences are stored. If they
              are stored in episodes, replay_sequence_length is ignored.
              If they are stored in episodes, replay_sequence_length is
              ignored.
          num_shards: The number of buffer shards that exist in total
              (including this one).
          replay_mode: One of "independent" or "lockstep". Determines,
              whether batches are sampled independently or to an equal
              amount.
          replay_sequence_override: If True, ignore sequences found in incoming
              batches, slicing them into sequences as specified by
              `replay_sequence_length` and `replay_sequence_burn_in`. This only has
              an effect if storage_unit is `sequences`.
          replay_sequence_length: The sequence length (T) of a single
              sample. If > 1, we will sample B x T from this buffer.
          replay_burn_in: The burn-in length in case
              `replay_sequence_length` > 0. This is the number of timesteps
              each sequence overlaps with the previous one to generate a
              better internal state (=state after the burn-in), instead of
              starting from 0.0 each RNN rollout.
          replay_zero_init_states: Whether the initial states in the
              buffer (if replay_sequence_length > 0) are alwayas 0.0 or
              should be updated with the previous train_batch state outputs.
          underlying_buffer_config: A config that contains all necessary
              constructor arguments and arguments for methods to call on
              the underlying buffers. This replaces the standard behaviour
              of the underlying PrioritizedReplayBuffer. The config
              follows the conventions of the general
              replay_buffer_config. kwargs for subsequent calls of methods
              may also be included. Example:
              "replay_buffer_config": {"type": PrioritizedReplayBuffer,
              "capacity": 10, "storage_unit": "timesteps",
              prioritized_replay_alpha: 0.5, prioritized_replay_beta: 0.5,
              prioritized_replay_eps: 0.5}
          prioritized_replay_alpha: Alpha parameter for a prioritized
              replay buffer. Use 0.0 for no prioritization.
          prioritized_replay_beta: Beta parameter for a prioritized
              replay buffer.
          prioritized_replay_eps: Epsilon parameter for a prioritized
              replay buffer.
          ``**kwargs``: Forward compatibility kwargs.
      """
      if "replay_mode" in kwargs and (
          kwargs["replay_mode"] == "lockstep"
          or kwargs["replay_mode"] == ReplayMode.LOCKSTEP
      ):
          if log_once("lockstep_mode_not_supported"):
              logger.error(
                  "Replay mode `lockstep` is not supported for "
                  "MultiAgentPrioritizedReplayBuffer. "
                  "This buffer will run in `independent` mode."
              )
          kwargs["replay_mode"] = "independent"
  
      if underlying_buffer_config is not None:
          if log_once("underlying_buffer_config_not_supported"):
              logger.info(
                  "PrioritizedMultiAgentReplayBuffer instantiated "
                  "with underlying_buffer_config. This will "
                  "overwrite the standard behaviour of the "
                  "underlying PrioritizedReplayBuffer."
              )
          prioritized_replay_buffer_config = underlying_buffer_config
      else:
          prioritized_replay_buffer_config = {
              "type": PrioritizedReplayBuffer,
              "alpha": prioritized_replay_alpha,
              "beta": prioritized_replay_beta,
          }
  
      shard_capacity = capacity // num_shards
      MultiAgentReplayBuffer.__init__(
          self,
          capacity=shard_capacity,
          storage_unit=storage_unit,
          replay_sequence_override=replay_sequence_override,
          replay_mode=replay_mode,
          replay_sequence_length=replay_sequence_length,
          replay_burn_in=replay_burn_in,
          replay_zero_init_states=replay_zero_init_states,
          underlying_buffer_config=prioritized_replay_buffer_config,
          **kwargs,
      )
  
      self.prioritized_replay_eps = prioritized_replay_eps
      self.update_priorities_timer = _Timer()
  
imports: from typing import Dict
  import logging
  import numpy
  from ray.util.timer import _Timer
  from ray.rllib.utils.annotations import override
  from ray.rllib.utils.replay_buffers.multi_agent_replay_buffer import MultiAgentReplayBuffer, ReplayMode, merge_dicts_with_warning
  from ray.rllib.utils.replay_buffers.prioritized_replay_buffer import PrioritizedReplayBuffer
  from ray.rllib.utils.replay_buffers.replay_buffer import StorageUnit
  from ray.rllib.utils.typing import PolicyID, SampleBatchType
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.util.debug import log_once
  from ray.util.annotations import DeveloperAPI
  from ray.rllib.policy.rnn_sequencing import timeslice_along_seq_lens_with_overlap
label_desc: Use image node_id 1 to create a new MultiAgentPrioritizedReplayBuffer object from inherited base classes: MultiAgentReplayBuffer, PrioritizedReplayBuffer with example: obj = MultiAgentPrioritizedReplayBuffer(capacity, storage_unit, num_shards, replay_mode, replay_sequence_override, replay_sequence_length, replay_burn_in, replay_zero_init_states, underlying_buffer_config, prioritized_replay_alpha, prioritized_replay_beta, prioritized_replay_eps)