docstr: Test sampling of episodes.
docstr_tok: ["Test","sampling","of","episodes","."]
code: def test_mixin_sampling_episodes(self):
      """Test sampling of episodes."""
      # 50% replay ratio.
      buffer = MultiAgentMixInReplayBuffer(
          capacity=self.capacity,
          storage_unit="episodes",
          replay_ratio=0.5,
      )
  
      # If we insert and replay n times, expect roughly return batches of
      # len 5 (replay_ratio=0.5 -> 50% replayed samples -> 1 new and 1
      # old sample, each of length two on average in each returned value).
      results = []
      batch = self._generate_episodes()
      for _ in range(20):
          buffer.add(batch)
          sample = buffer.sample(2)
          assert type(sample) == MultiAgentBatch
          results.append(len(sample.policy_batches[DEFAULT_POLICY_ID]))
      # One sample in the episode does not belong the the episode on thus
      # gets dropped. Full episodes are of length two.
      self.assertAlmostEqual(np.mean(results), 2 * (len(batch) - 1))
  
file_path: ray/rllib/utils/replay_buffers/tests/test_multi_agent_mixin_replay_buffer.py
imports: import numpy
  import unittest
  from ray.rllib.utils.replay_buffers.multi_agent_mixin_replay_buffer import MultiAgentMixInReplayBuffer
  from ray.rllib.policy.sample_batch import SampleBatch, DEFAULT_POLICY_ID, MultiAgentBatch
label_desc: Use image node_id 3 for calling the TestMixInMultiAgentReplayBuffer obj's underlying member method code with example usage: obj.test_mixin_sampling_episodes() without return types