code: def attribute(
      self, _, op_type
  ):  # pylint: disable=missing-function-docstring,too-many-branches
      if _.type == _AttributeType.UNDEFINED:
          attribute_type = None
          value = None
      elif _.type == _AttributeType.FLOAT:
          attribute_type = "float32"
          value = _.f
      elif _.type == _AttributeType.INT:
          attribute_type = "int64"
          value = _.i
      elif _.type == _AttributeType.STRING:
          attribute_type = "string"
          value = _.s.decode(
              "latin1" if op_type == "Int8GivenTensorFill" else "utf-8"
          )
      elif _.type == _AttributeType.TENSOR:
          attribute_type = "tensor"
          value = self._tensor(_.t)
      elif _.type == _AttributeType.GRAPH:
          attribute_type = "tensor"
          raise Exception(
              "Unsupported graph attribute type"
          )  # pylint: disable=broad-exception-raised
      elif _.type == _AttributeType.FLOATS:
          attribute_type = "float32[]"
          value = list(_.floats)
      elif _.type == _AttributeType.INTS:
          attribute_type = "int64[]"
          value = list(_.ints)
      elif _.type == _AttributeType.STRINGS:
          attribute_type = "string[]"
          value = [item.decode("utf-8") for item in _.strings]
      elif _.type == _AttributeType.TENSORS:
          attribute_type = "tensor[]"
          raise Exception(
              "Unsupported tensors attribute type"
          )  # pylint: disable=broad-exception-raised
      elif _.type == _AttributeType.GRAPHS:
          attribute_type = "graph[]"
          raise Exception(
              "Unsupported graphs attribute type"
          )  # pylint: disable=broad-exception-raised
      elif _.type == _AttributeType.SPARSE_TENSOR:
          attribute_type = "tensor"
          value = self._tensor(_.sparse_tensor)
      else:
          raise Exception(
              "Unsupported attribute type '" + str(_.type) + "'."
          )  # pylint: disable=broad-exception-raised
      json_attribute = {}
      json_attribute["name"] = _.name
      if attribute_type:
          json_attribute["type"] = attribute_type
      json_attribute["value"] = value
      return json_attribute
  
imports: import collections
  import enum
  import json
  import os
label_desc: Use image node_id 4 for calling the _Graph obj's underlying member method code with example usage: obj.attribute(_, op_type) and returns: json_attribute