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: Checks if the observation space contains the given key.
  
  Args:
      x: Observations to check.
  
  Returns:
      True if the observation space contains the given all observations
          in x.
docstr_tok: ["Checks","if","the","observation","space","contains","the","given","key",".","Args",":","x",":","Observations","to","check",".","Returns",":","True","if","the","observation","space","contains","the","given","all","observations","in","x","."]
code: def observation_space_contains(self, x: MultiAgentDict) -> bool:
      """Checks if the observation space contains the given key.
  
      Args:
          x: Observations to check.
  
      Returns:
          True if the observation space contains the given all observations
              in x.
      """
      if (
          not hasattr(self, "_obs_space_in_preferred_format")
          or self._obs_space_in_preferred_format is None
      ):
          self._obs_space_in_preferred_format = (
              self._check_if_obs_space_maps_agent_id_to_sub_space()
          )
      if self._obs_space_in_preferred_format:
          for key, agent_obs in x.items():
              if not self.observation_space[key].contains(agent_obs):
                  return False
          if not all(k in self.observation_space.spaces for k in x):
              if log_once(
                  "possibly_bad_multi_agent_dict_missing_agent_observations"
              ):
                  logger.warning(
                      "You environment returns observations that are "
                      "MultiAgentDicts with incomplete information. "
                      "Meaning that they only contain information on a subset of"
                      " participating agents. Ignore this warning if this is "
                      "intended, for example if your environment is a turn-based "
                      "simulation."
                  )
          return True
  
      logger.warning(
          "observation_space_contains() of {} 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. ".format(self)
      )
      return True
  
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 4 for calling the MultiAgentEnv obj's underlying member method code with example usage: obj.observation_space_contains(x) and returns: True, True, False