class_docstr: PySC2 environment converter.
  
  Converts the PySC2 observation/action interface, supporting more standard
  interaction with an ML agent and providing enriched observations.
  
  Limited configuration is supported through the `ConverterSettings` proto.
  In particular, clients may choose between 'visual' and 'raw' interfaces.
  The visual interface focuses on spatial features and actions which are close
  to those used by a human when playing the game. The raw interface retains
  some spatial features but focuses on numeric unit data; actions being
  specified to units directly, ignoring e.g. the position of the camera.
  
  The converter maintains some state throughout an episode. This state relies
  on convert_observation and convert_action being called alternately
  throughout the episde. A new converter should be created for each episode.
docstr: Converts an agent action into an SC2 API action proto.
  
  Note that the returned action also carries the game loop delay requested
  by this player until the next observation.
  
  Args:
    action: A flat mapping of string labels to numpy arrays / or scalars.
  
  Returns:
    An SC2 API action request + game loop delay.
docstr_tok: ["Converts","an","agent","action","into","an","SC2","API","action","proto",".","Note","that","the","returned","action","also","carries","the","game","loop","delay","requested","by","this","player","until","the","next","observation",".","Args",":","action",":","A","flat","mapping","of","string","labels","to","numpy","arrays","\/","or","scalars",".","Returns",":","An","SC2","API","action","request","+","game","loop","delay","."]
code: def convert_action(
      self, action: Mapping[str, Any]
  ) -> converter_pb2.Action:
      """Converts an agent action into an SC2 API action proto.
  
      Note that the returned action also carries the game loop delay requested
      by this player until the next observation.
  
      Args:
        action: A flat mapping of string labels to numpy arrays / or scalars.
  
      Returns:
        An SC2 API action request + game loop delay.
      """
      # TODO(b/210113354): Remove protos serialization over pybind11 boundary.
      serialized_action = {
          k: tensor_utils.pack_tensor(v).SerializeToString()
          for k, v in action.items()
      }
      converted_action_serialized = self._converter.ConvertAction(
          serialized_action
      )
      converted_action = converter_pb2.Action()
      converted_action.ParseFromString(converted_action_serialized)
  
      request_action = sc2api_pb2.RequestAction()
      request_action.ParseFromString(
          converted_action.request_action.SerializeToString()
      )
      return converter_pb2.Action(
          request_action=request_action, delay=converted_action.delay
      )
  
file_path: pysc2/pysc2/env/converter/converter.py
imports: from typing import Any, Mapping
  from dm_env import specs
  from pysc2.env.converter.cc.python import converter
  from pysc2.env.converter.proto import converter_pb2
  from dm_env_rpc.v1 import dm_env_rpc_pb2
  from dm_env_rpc.v1 import dm_env_utils
  from dm_env_rpc.v1 import tensor_utils
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 5 for calling the Converter obj's underlying member method code with example usage: obj.convert_action(action) and returns: converter_pb2