def parse_agent_interface_format(
    feature_screen=None,
    feature_minimap=None,
    rgb_screen=None,
    rgb_minimap=None,
    action_space=None,
    camera_width_world_units=None,
    use_feature_units=False,
    use_raw_units=False,
    use_unit_counts=False,
    use_camera_position=False):
  """Creates an AgentInterfaceFormat object from keyword args.

  Convenient when using dictionaries or command-line arguments for config.

  Note that the feature_* and rgb_* properties define the respective spatial
  observation dimensions and accept:
      * None or 0 to disable that spatial observation.
      * A single int for a square observation with that side length.
      * A (int, int) tuple for a rectangular (width, height) observation.

  Args:
    feature_screen: If specified, so must feature_minimap be.
    feature_minimap: If specified, so must feature_screen be.
    rgb_screen: If specified, so must rgb_minimap be.
    rgb_minimap: If specified, so must rgb_screen be.
    action_space: ["FEATURES", "RGB"].
    camera_width_world_units: An int.
    use_feature_units: A boolean, defaults to False.
    use_raw_units: A boolean, defaults to False.
    use_unit_counts: A boolean, defaults to False.
    use_camera_position: A boolean, defaults to False.

  Returns:
    An `AgentInterfaceFormat` object.

  Raises:
    ValueError: If an invalid parameter is specified.
  """
  if feature_screen or feature_minimap:
    feature_dimensions = Dimensions(
        screen=feature_screen,
        minimap=feature_minimap)
  else:
    feature_dimensions = None

  if rgb_screen or rgb_minimap:
    rgb_dimensions = Dimensions(
        screen=rgb_screen,
        minimap=rgb_minimap)
  else:
    rgb_dimensions = None

  return AgentInterfaceFormat(
      feature_dimensions=feature_dimensions,
      rgb_dimensions=rgb_dimensions,
      action_space=(action_space and actions.ActionSpace[action_space.upper()]),
      camera_width_world_units=camera_width_world_units,
      use_feature_units=use_feature_units,
      use_raw_units=use_raw_units,
      use_unit_counts=use_unit_counts,
      use_camera_position=use_camera_position
  )