code: def _check_if_multi_env_dict(env, element, function_string):
      if not isinstance(element, dict):
          raise ValueError(
              f"The element returned by {function_string} is not a "
              f"MultiEnvDict. Instead, it is of type: {type(element)}"
          )
      env_ids = env.get_sub_environments(as_dict=True).keys()
      if not all(k in env_ids for k in element):
          raise ValueError(
              f"The element returned by {function_string} "
              f"has dict keys that don't correspond to "
              f"environment ids for this env "
              f"{list(env_ids)}"
          )
      for _, multi_agent_dict in element.items():
          _check_if_element_multi_agent_dict(
              env, multi_agent_dict, function_string, base_env=True
          )
  
imports: import logging
  import traceback
  from copy import copy
  from typing import TYPE_CHECKING, Optional, Set, Union
  import numpy
  import tree
  from ray.actor import ActorHandle
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.error import ERR_MSG_OLD_GYM_API, UnsupportedSpaceException
  from ray.rllib.utils.gym import check_old_gym_env, try_import_gymnasium_and_gym
  from ray.rllib.utils.spaces.space_utils import convert_element_to_space_type, get_base_struct_from_space
  from ray.rllib.utils.typing import EnvType
  from ray.util import log_once
label_desc: Use image node_id 10 for calling a global function with example usage: _check_if_multi_env_dict(env, element, function_string) without return types