code: def assign_attr_value(attr, val):
      """Assign value to AttrValue proto according to data type."""
      if isinstance(val, bool):
          attr.b = val
      elif isinstance(val, six.integer_types):
          attr.i = val
      elif isinstance(val, float):
          attr.f = val
      elif isinstance(val, str):
          attr.s = val.encode("utf-8")
      elif isinstance(val, TensorShape):
          attr.shape.MergeFromString(val.SerializeToString())
      elif isinstance(val, list):
          if len(val) == 0:
              return
  
          if isinstance(val[0], six.integer_types):
              attr.list.i.extend(val)
          elif isinstance(val[0], TensorShape):
              attr.list.shape.extend(val)
          else:
              raise NotImplementedError(
                  "AttrValue cannot be of %s %s"
                  % (type(val), type(val[0]))
              )
      else:
          raise NotImplementedError(
              "AttrValue cannot be of %s" % type(val)
          )
  
imports: import six
  from six import string_types
  from mmdnn.conversion.caffe.errors import ConversionError
  from mmdnn.conversion.common.IR.graph_pb2 import GraphDef, NodeDef, TensorShape
  from mmdnn.conversion.caffe.utils import get_real_name
label_desc: Use image node_id 1 for calling a global function with example usage: assign_attr_value(attr, val) without return types