docstr: Test the independent mode with sequences as a storage unit.
  
  Such SampleBatches are converted to MultiAgentBatches as if there
  was only one policy.
docstr_tok: ["Test","the","independent","mode","with","sequences","as","a","storage","unit",".","Such","SampleBatches","are","converted","to","MultiAgentBatches","as","if","there","was","only","one","policy","."]
code: def test_independent_mode_sequences_storage_unit(self):
      """Test the independent mode with sequences as a storage unit.
  
      Such SampleBatches are converted to MultiAgentBatches as if there
      was only one policy."""
      buffer_size = 15
      self.batch_id = 0
  
      buffer = MultiAgentReplayBuffer(
          capacity=buffer_size,
          replay_mode="independent",
          storage_unit="sequences",
          replay_sequence_length=2,
          num_shards=1,
      )
  
      # Test add/sample
      self._add_multi_agent_batch_to_buffer(
          buffer, num_policies=2, num_batches=1, seq_lens=True
      )
  
      # Sampling from it now should yield the first batch
      assert get_batch_id(buffer.sample(1), 0) == 0
  
      self._add_multi_agent_batch_to_buffer(
          buffer, num_policies=2, num_batches=2, seq_lens=True
      )
  
      # Sampling from it now should yield each batch that went into a
      # multiagent batch 1/6th of the time
      num_sampled_dict = {_id: 0 for _id in range(self.batch_id)}
      num_samples = 200
      for i in range(num_samples):
          sample = buffer.sample(1)
          # Count one of both policy batches
          _id = get_batch_id(sample, np.random.choice([0, 1]))
          num_sampled_dict[_id] += 1
          # See if a random batch has the desired sequence length of two
          assert (
              len(sample.policy_batches[np.random.choice([0, 1])]) == 2
          )
      assert np.allclose(
          np.array(list(num_sampled_dict.values())) / num_samples,
          len(num_sampled_dict) * [1 / 6],
          atol=0.1,
      )
  
file_path: ray/rllib/utils/replay_buffers/tests/test_multi_agent_replay_buffer.py
imports: import unittest
  import numpy
  from ray.rllib.policy.sample_batch import SampleBatch, MultiAgentBatch, concat_samples
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
  from ray.rllib.utils.replay_buffers.multi_agent_replay_buffer import MultiAgentReplayBuffer
  from ray.rllib.utils.replay_buffers.prioritized_replay_buffer import PrioritizedReplayBuffer
  from ray.rllib.utils.replay_buffers.replay_buffer import ReplayBuffer
label_desc: Use image node_id 5 for calling the TestMultiAgentReplayBuffer obj's underlying member method code with example usage: obj.test_independent_mode_sequences_storage_unit() without return types