class_docstr: Wraps a MultiAgentEnv environment with agents grouped as specified.
  
  See multi_agent_env.py for the specification of groups.
  
  This API is experimental.
class_docstr_tok: ["Wraps","a","MultiAgentEnv","environment","with","agents","grouped","as","specified",".","See","multi_agent_env.py","for","the","specification","of","groups",".","This","API","is","experimental","."]
code: def _group_items(
      self, items, agg_fn=lambda gvals: list(gvals.values())
  ):
      grouped_items = {}
      for agent_id, item in items.items():
          if agent_id in self.agent_id_to_group:
              group_id = self.agent_id_to_group[agent_id]
              if group_id in grouped_items:
                  continue  # already added
              group_out = OrderedDict()
              for a in self.groups[group_id]:
                  if a in items:
                      group_out[a] = items[a]
                  else:
                      raise ValueError(
                          "Missing member of group {}: {}: {}".format(
                              group_id, a, items
                          )
                      )
              grouped_items[group_id] = agg_fn(group_out)
          else:
              grouped_items[agent_id] = item
      return grouped_items
  
file_path: ray/rllib/env/wrappers/group_agents_wrapper.py
imports: from collections import OrderedDict
  import gymnasium
  from typing import Dict, List, Optional
  from ray.rllib.env.multi_agent_env import MultiAgentEnv
  from ray.rllib.utils.annotations import DeveloperAPI
  from ray.rllib.utils.typing import AgentID
label_desc: Use image node_id 5 for calling the GroupAgentsWrapper obj's underlying member method code with example usage: obj._group_items(items, agg_fn) and returns: grouped_items