class_docstr: Tracks the current state of a (possibly multi-agent) episode.
class_docstr_tok: ["Tracks","the","current","state","of","a","(","possibly","multi-agent",")","episode","."]
docstr: Get the index of an agent among its environment.
  
  A new index will be created if an agent is seen for the first time.
  
  Args:
      agent_id: ID of an agent.
  
  Returns:
      The index of this agent.
docstr_tok: ["Get","the","index","of","an","agent","among","its","environment",".","A","new","index","will","be","created","if","an","agent","is","seen","for","the","first","time",".","Args",":","agent_id",":","ID","of","an","agent",".","Returns",":","The","index","of","this","agent","."]
code: def agent_index(self, agent_id: AgentID) -> int:
      """Get the index of an agent among its environment.
  
      A new index will be created if an agent is seen for the first time.
  
      Args:
          agent_id: ID of an agent.
  
      Returns:
          The index of this agent.
      """
      if agent_id not in self._agent_to_index:
          self._agent_to_index[agent_id] = self._next_agent_index
          self._next_agent_index += 1
      return self._agent_to_index[agent_id]
  
imports: import random
  from collections import defaultdict
  import numpy
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple
  from ray.rllib.env.base_env import _DUMMY_AGENT_ID
  from ray.rllib.evaluation.collectors.simple_list_collector import _PolicyCollector, _PolicyCollectorGroup
  from ray.rllib.evaluation.collectors.agent_collector import AgentCollector
  from ray.rllib.policy.policy_map import PolicyMap
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.typing import AgentID, EnvID, EnvInfoDict, PolicyID, TensorType
label_desc: Use image node_id 4 for calling the EpisodeV2 obj's underlying member method code with example usage: obj.agent_index(agent_id) and returns: self