code: def to_dict(map_proto: MapProto) -> Dict[Any, Any]:
      """Converts a map def to a Python dictionary.
  
      Args:
          map_proto: a MapProto object.
  
      Returns:
          The converted dictionary.
      """
      key_list: List[Any] = []
      if map_proto.key_type == TensorProto.STRING:
          key_list = list(map_proto.string_keys)
      else:
          key_list = list(map_proto.keys)
  
      value_list = to_list(map_proto.values)
      if len(key_list) != len(value_list):
          raise IndexError(
              "Length of keys and values for MapProto (map name: ",
              map_proto.name,
              ") are not the same.",
          )
      dictionary = dict(zip(key_list, value_list))
      return dictionary
  
imports: import sys
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  import numpy
  from onnx import MapProto, OptionalProto, SequenceProto, TensorProto, helper, subbyte
  from onnx.external_data_helper import load_external_data_for_tensor, uses_external_data
label_desc: Use image node_id 12 for calling a global function with example usage: to_dict(map_proto) and returns: dictionary