class_docstr: Data bits that may be needed for running connectors.
  
  Note(jungong) : we need to be really careful with the data fields here.
  E.g., everything needs to be serializable, in case we need to fetch them
  in a remote setting.
class_docstr_tok: ["Data","bits","that","may","be","needed","for","running","connectors",".","Note","(","jungong",")",":","we","need","to","be","really","careful","with","the","data","fields","here",".","E.g.",",","everything","needs","to","be","serializable",",","in","case","we","need","to","fetch","them","in","a","remote","setting","."]
docstr: Build ConnectorContext from a given policy.
  
  Args:
      policy: Policy
  
  Returns:
      A ConnectorContext instance.
docstr_tok: ["Build","ConnectorContext","from","a","given","policy",".","Args",":","policy",":","Policy","Returns",":","A","ConnectorContext","instance","."]
code: def from_policy(policy: "Policy") -> "ConnectorContext":
      """Build ConnectorContext from a given policy.
  
      Args:
          policy: Policy
  
      Returns:
          A ConnectorContext instance.
      """
      return ConnectorContext(
          config=policy.config,
          initial_states=policy.get_initial_state(),
          observation_space=policy.observation_space,
          action_space=policy.action_space,
          view_requirements=policy.view_requirements,
          is_policy_recurrent=policy.is_recurrent(),
      )
  
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 2 for calling the ConnectorContext obj's underlying member method code with example usage: obj.from_policy(policy) and returns: ConnectorContext