code: def to_optional(optional: OptionalProto) -> Optional[Any]:
      """Converts an optional def to a Python optional.
  
      Args:
          optional: an OptionalProto object.
  
      Returns:
          opt: the converted optional.
      """
      elem_type = optional.elem_type
      if elem_type == OptionalProto.UNDEFINED:
          return None
      if elem_type == OptionalProto.TENSOR:
          return to_array(optional.tensor_value)
      if elem_type == OptionalProto.SPARSE_TENSOR:
          return to_array(optional.sparse_tensor_value)  # type: ignore[arg-type]
      if elem_type == OptionalProto.SEQUENCE:
          return to_list(optional.sequence_value)
      if elem_type == OptionalProto.MAP:
          return to_dict(optional.map_value)
      if elem_type == OptionalProto.OPTIONAL:
          return to_optional(optional.optional_value)
      raise TypeError(
          "The element type in the input optional is not supported."
      )
  
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 14 for calling a global function with example usage: to_optional(optional) and returns: None, to_array, to_array, to_list, to_dict, to_optional