code: def test_init(self):
      # Create an empty episode.
      episode = MultiAgentEpisode()
      # Empty episode should have a start point and count of zero.
      self.assertTrue(episode.t_started == episode.t == 0)
  
      # Create an episode with a specific starting point.
      episode = MultiAgentEpisode(t_started=10)
      self.assertTrue(episode.t == episode.t_started == 10)
  
      # Sample 100 values and initialize the episode with observations.
      env = MultiAgentTestEnv()
      # Initialize containers.
      observations = []
      rewards = []
      actions = []
      infos = []
      terminateds = {}
      truncateds = {}
      extra_model_outputs = []
      # Initialize observation and info.
      obs, info = env.reset(seed=0)
      observations.append(obs)
      infos.append(info)
      # Run 100 samples.
      for i in range(100):
          agents_to_step_next = [
              aid for aid in obs.keys() if aid in env._agents_alive
          ]
          action = {agent_id: i + 1 for agent_id in agents_to_step_next}
          # action = env.action_space_sample(agents_stepped)
          obs, reward, terminated, truncated, info = env.step(action)
          observations.append(obs)
          actions.append(action)
          rewards.append(reward)
          infos.append(info)
          terminateds.update(terminated)
          truncateds.update(truncated)
          extra_model_outputs.append(
              {
                  agent_id: {"extra_1": 10.5}
                  for agent_id in agents_to_step_next
              }
          )
  
      # Now create the episode from the recorded data.
      episode = MultiAgentEpisode(
          agent_ids=list(env.get_agent_ids()),
          observations=observations,
          actions=actions,
          rewards=rewards,
          infos=infos,
          terminateds=terminateds,
          truncateds=truncateds,
          extra_model_outputs=extra_model_outputs,
      )
  
      # The starting point and count should now be at `len(observations) - 1`.+
      self.assertTrue(
          episode.t == episode.t_started == (len(observations) - 1)
      )
      # Assert that agent 1 and agent 5 are both terminated.
      self.assertTrue(episode.agent_episodes["agent_1"].is_terminated)
      self.assertTrue(episode.agent_episodes["agent_5"].is_terminated)
      # Assert that the other agents are neither terminated nor truncated.
      for agent_id in env.get_agent_ids():
          if agent_id != "agent_1" and agent_id != "agent_5":
              self.assertFalse(episode.agent_episodes[agent_id].is_done)
      # Ensure that all global reward lists match in length the global reward
      # timestep mappings.
      for agent_id in episode._agent_ids:
          self.assertEqual(
              len(episode.partial_rewards[agent_id]),
              len(episode.partial_rewards_t[agent_id]),
          )
  
      # Test now intiializing an episode and setting the starting timestep at once.
      episode = MultiAgentEpisode(
          agent_ids=list(env._agents_alive) + ["agent_5"],
          observations=observations[-11:],
          actions=actions[-10:],
          rewards=rewards[-10:],
          infos=infos[-11:],
          t_started=100,
          terminateds=terminateds,
          truncateds=truncateds,
          extra_model_outputs=extra_model_outputs[-10:],
      )
  
      # Assert that the episode starts indeed at 100.
      self.assertEqual(episode.t, episode.t_started, 100)
      # Assert that the highest index in the timestep mapping is indeed 10.
      highest_index = max(
          [
              max(timesteps)
              for timesteps in episode.global_t_to_local_t.values()
              if len(timesteps) > 0
          ]
      )
      self.assertGreaterEqual(100, highest_index)
      # Assert that agent 5 is terminated.
      self.assertTrue(episode.agent_episodes["agent_5"].is_terminated)
  
      # Now test, if agents that have never stepped are handled correctly.
      # agent 5 will be the agent that never stepped.
      (
          observations,
          actions,
          rewards,
          terminateds,
          truncateds,
          infos,
      ) = self._mock_multi_agent_records()
  
      # Create the episode from the mock data.
      episode = MultiAgentEpisode(
          agent_ids=[
              "agent_1",
              "agent_2",
              "agent_3",
              "agent_4",
              "agent_5",
          ],
          observations=observations,
          actions=actions,
          rewards=rewards,
          infos=infos,
          terminateds=terminateds,
          truncateds=truncateds,
      )
  
      # Assert that the length of `SingleAgentEpisode`s are all correct.
      self.assertEqual(len(episode.agent_episodes["agent_1"]), 1)
      self.assertEqual(len(episode.agent_episodes["agent_2"]), 1)
      self.assertEqual(len(episode.agent_episodes["agent_3"]), 1)
      self.assertEqual(len(episode.agent_episodes["agent_4"]), 1)
      self.assertEqual(len(episode.agent_episodes["agent_5"]), 0)
  
imports: import gymnasium
  import numpy
  import unittest
  from typing import List, Optional, Tuple
  import ray
  from ray.rllib.env.multi_agent_env import MultiAgentEnv
  from ray.rllib.env.multi_agent_episode import MultiAgentEpisode
  from ray.rllib.utils.typing import MultiAgentDict
label_desc: Use image node_id 3 for calling the TestMultiAgentEpisode obj's underlying member method code with example usage: obj.test_init() without return types