code: def _convertAttributeProto(
      onnx_arg,
  ):  # type: (AttributeProto) -> AttributeValue
      """
      Convert an ONNX AttributeProto into an appropriate Python object
      for the type.
      NB: Tensor attribute gets returned as numpy array
      """
      if onnx_arg.HasField("f"):
          return onnx_arg.f
      elif onnx_arg.HasField("i"):
          return onnx_arg.i
      elif onnx_arg.HasField("s"):
          return onnx_arg.s
      elif onnx_arg.HasField("t"):
          return numpy_helper.to_array(onnx_arg.t)
      elif len(onnx_arg.floats):
          return list(onnx_arg.floats)
      elif len(onnx_arg.ints):
          return list(onnx_arg.ints)
      elif len(onnx_arg.strings):
          return list(onnx_arg.strings)
      else:
          raise ValueError(
              "Unsupported ONNX attribute: {}".format(onnx_arg)
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from onnx import numpy_helper, ValueInfoProto, AttributeProto, GraphProto, NodeProto, TensorProto, TensorShapeProto
  from typing import Any, Text, Iterable, List, Dict, Sequence, Optional, Tuple, Union
  from typing_extensions import Protocol
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: _convertAttributeProto(onnx_arg) and returns: onnx_arg, onnx_arg, onnx_arg, numpy_helper, list, list, list