class_docstr: An environment that hosts multiple independent agents.
  
  Agents are identified by (string) agent ids. Note that these "agents" here
  are not to be confused with RLlib Algorithms, which are also sometimes
  referred to as "agents" or "RL agents".
  
  The preferred format for action- and observation space is a mapping from agent
  ids to their individual spaces. If that is not provided, the respective methods'
  observation_space_contains(), action_space_contains(),
  action_space_sample() and observation_space_sample() have to be overwritten.
class_docstr_tok: ["An","environment","that","hosts","multiple","independent","agents",".","Agents","are","identified","by","(","string",")","agent","ids",".","Note","that","these","``","agents","''","here","are","not","to","be","confused","with","RLlib","Algorithms",",","which","are","also","sometimes","referred","to","as","``","agents","''","or","``","RL","agents","''",".","The","preferred","format","for","action-","and","observation","space","is","a","mapping","from","agent","ids","to","their","individual","spaces",".","If","that","is","not","provided",",","the","respective","methods'","observation_space_contains","(",")",",","action_space_contains","(",")",",","action_space_sample","(",")","and","observation_space_sample","(",")","have","to","be","overwritten","."]
docstr: Returns a random action for each environment, and potentially each
      agent in that environment.
  
  Args:
      agent_ids: List of agent ids to sample actions for. If None or
          empty list, sample actions for all agents in the
          environment.
  
  Returns:
      A random action for each environment.
docstr_tok: ["Returns","a","random","action","for","each","environment",",","and","potentially","each","agent","in","that","environment",".","Args",":","agent_ids",":","List","of","agent","ids","to","sample","actions","for",".","If","None","or","empty","list",",","sample","actions","for","all","agents","in","the","environment",".","Returns",":","A","random","action","for","each","environment","."]
code: def action_space_sample(
      self, agent_ids: list = None
  ) -> MultiAgentDict:
      """Returns a random action for each environment, and potentially each
          agent in that environment.
  
      Args:
          agent_ids: List of agent ids to sample actions for. If None or
              empty list, sample actions for all agents in the
              environment.
  
      Returns:
          A random action for each environment.
      """
      if (
          not hasattr(self, "_action_space_in_preferred_format")
          or self._action_space_in_preferred_format is None
      ):
          self._action_space_in_preferred_format = (
              self._check_if_action_space_maps_agent_id_to_sub_space()
          )
      if self._action_space_in_preferred_format:
          if agent_ids is None:
              agent_ids = self.get_agent_ids()
          samples = self.action_space.sample()
          return {
              agent_id: samples[agent_id]
              for agent_id in agent_ids
              if agent_id != "__all__"
          }
      logger.warning(
          f"action_space_sample() of {self} has not been implemented. "
          "You can either implement it yourself or bring the observation "
          "space into the preferred format of a mapping from agent ids "
          "to their individual observation spaces."
      )
      return {}
  
imports: import gymnasium
  import logging
  from typing import Callable, Dict, List, Tuple, Optional, Union, Set, Type
  from ray.rllib.env.base_env import BaseEnv
  from ray.rllib.env.env_context import EnvContext
  from ray.rllib.utils.annotations import ExperimentalAPI, override, PublicAPI, DeveloperAPI
  from ray.rllib.utils.typing import AgentID, EnvCreator, EnvID, EnvType, MultiAgentDict, MultiEnvDict
  from ray.util import log_once
label_desc: Use image node_id 6 for calling the MultiAgentEnv obj's underlying member method code with example usage: obj.action_space_sample(agent_ids) and returns: dict, unknown