class_docstr: Connector connecting user environments to RLlib policies.
  
  An agent connector transforms a list of agent data in AgentConnectorDataType
  format into a new list in the same AgentConnectorDataTypes format.
  The input API is designed so agent connectors can have access to all the
  agents assigned to a particular policy.
  
  AgentConnectorDataTypes can be used to specify arbitrary type of env data,
  
  Example:
  
      Represent a list of agent data from one env step() call.
  
      .. testcode::
  
          import numpy as np
          ac = AgentConnectorDataType(
              env_id="env_1",
              agent_id=None,
              data={
                  "agent_1": np.array([1, 2, 3]),
                  "agent_2": np.array([4, 5, 6]),
              }
          )
  
      Or a single agent data ready to be preprocessed.
  
      .. testcode::
  
          ac = AgentConnectorDataType(
              env_id="env_1",
              agent_id="agent_1",
              data=np.array([1, 2, 3]),
          )
  
      We can also adapt a simple stateless function into an agent connector by
      using register_lambda_agent_connector:
  
      .. testcode::
  
          import numpy as np
          from ray.rllib.connectors.agent.lambdas import (
              register_lambda_agent_connector
          )
          TimesTwoAgentConnector = register_lambda_agent_connector(
              "TimesTwoAgentConnector", lambda data: data * 2
          )
  
          # More complicated agent connectors can be implemented by extending this
          # AgentConnector class:
  
          class FrameSkippingAgentConnector(AgentConnector):
              def __init__(self, n):
                  self._n = n
                  self._frame_count = default_dict(str, default_dict(str, int))
  
              def reset(self, env_id: str):
                  del self._frame_count[env_id]
  
              def __call__(
                  self, ac_data: List[AgentConnectorDataType]
              ) -> List[AgentConnectorDataType]:
                  ret = []
                  for d in ac_data:
                      assert d.env_id and d.agent_id, "Skipping works per agent!"
  
                      count = self._frame_count[ac_data.env_id][ac_data.agent_id]
                      self._frame_count[ac_data.env_id][ac_data.agent_id] = (
                          count + 1
                      )
  
                      if count % self._n == 0:
                          ret.append(d)
                  return ret
  
  As shown, an agent connector may choose to emit an empty list to stop input
  observations from being further prosessed.
class_docstr_tok: ["Connector","connecting","user","environments","to","RLlib","policies",".","An","agent","connector","transforms","a","list","of","agent","data","in","AgentConnectorDataType","format","into","a","new","list","in","the","same","AgentConnectorDataTypes","format",".","The","input","API","is","designed","so","agent","connectors","can","have","access","to","all","the","agents","assigned","to","a","particular","policy",".","AgentConnectorDataTypes","can","be","used","to","specify","arbitrary","type","of","env","data",",","Example",":","Represent","a","list","of","agent","data","from","one","env","step","(",")","call",".","..","testcode",":",":","import","numpy","as","np","ac","=","AgentConnectorDataType","(","env_id=","''","env_1","''",",","agent_id=None",",","data=","{","``","agent_1","''",":","np.array","(","[","1",",","2",",","3","]",")",",","``","agent_2","''",":","np.array","(","[","4",",","5",",","6","]",")",",","}",")","Or","a","single","agent","data","ready","to","be","preprocessed",".","..","testcode",":",":","ac","=","AgentConnectorDataType","(","env_id=","''","env_1","''",",","agent_id=","''","agent_1","''",",","data=np.array","(","[","1",",","2",",","3","]",")",",",")","We","can","also","adapt","a","simple","stateless","function","into","an","agent","connector","by","using","register_lambda_agent_connector",":","..","testcode",":",":","import","numpy","as","np","from","ray.rllib.connectors.agent.lambdas","import","(","register_lambda_agent_connector",")","TimesTwoAgentConnector","=","register_lambda_agent_connector","(","``","TimesTwoAgentConnector","''",",","lambda","data",":","data","*","2",")","#","More","complicated","agent","connectors","can","be","implemented","by","extending","this","#","AgentConnector","class",":","class","FrameSkippingAgentConnector","(","AgentConnector",")",":","def","__init__","(","self",",","n",")",":","self._n","=","n","self._frame_count","=","default_dict","(","str",",","default_dict","(","str",",","int",")",")","def","reset","(","self",",","env_id",":","str",")",":","del","self._frame_count","[","env_id","]","def","__call__","(","self",",","ac_data",":","List","[","AgentConnectorDataType","]",")","-",">","List","[","AgentConnectorDataType","]",":","ret","=","[","]","for","d","in","ac_data",":","assert","d.env_id","and","d.agent_id",",","``","Skipping","works","per","agent","!","''","count","=","self._frame_count","[","ac_data.env_id","]","[","ac_data.agent_id","]","self._frame_count","[","ac_data.env_id","]","[","ac_data.agent_id","]","=","(","count","+","1",")","if","count","%","self._n","==","0",":","ret.append","(","d",")","return","ret","As","shown",",","an","agent","connector","may","choose","to","emit","an","empty","list","to","stop","input","observations","from","being","further","prosessed","."]
docstr: Transform a single agent connector data item.
  
  Args:
      data: Env and agent IDs, plus arbitrary data item from a single agent
      of an environment.
  
  Returns:
      A transformed piece of agent connector data.
docstr_tok: ["Transform","a","single","agent","connector","data","item",".","Args",":","data",":","Env","and","agent","IDs",",","plus","arbitrary","data","item","from","a","single","agent","of","an","environment",".","Returns",":","A","transformed","piece","of","agent","connector","data","."]
code: def transform(
      self, ac_data: AgentConnectorDataType
  ) -> AgentConnectorDataType:
      """Transform a single agent connector data item.
  
      Args:
          data: Env and agent IDs, plus arbitrary data item from a single agent
          of an environment.
  
      Returns:
          A transformed piece of agent connector data.
      """
      raise NotImplementedError
  
imports: import abc
  import logging
  from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union
  import gymnasium
  from ray.rllib.policy.view_requirement import ViewRequirement
  from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType, AlgorithmConfigDict, TensorType
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 4 for calling the AgentConnector obj's underlying member method code with example usage: obj.transform(ac_data) without return types