code: def parse_tensor(t):
      typ = parse_type(t.dtype)
      shape = parse_shape(t.tensor_shape)
  
      retval = None
      if len(t.half_val) > 0:
          retval = _np.array(t.half_val, dtype=_TF_TO_NP[t.dtype])
      elif len(t.float_val) > 0:
          retval = _np.array(t.float_val, dtype=_TF_TO_NP[t.dtype])
      elif len(t.double_val) > 0:
          retval = _np.array(t.double_val, dtype=_TF_TO_NP[t.dtype])
      elif len(t.int_val) > 0:
          retval = _np.array(t.int_val, dtype=_TF_TO_NP[t.dtype])
      elif len(t.int64_val) > 0:
          retval = _np.array(t.int64_val, dtype=_TF_TO_NP[t.dtype])
      elif len(t.bool_val) > 0:
          retval = _np.array(t.bool_val, dtype=_TF_TO_NP[t.dtype])
      elif hasattr(t, "uint32_val") and len(t.uint32_val) > 0:
          retval = _np.array(t.uint32_val, dtype=_TF_TO_NP[t.dtype])
      elif hasattr(t, "uint64_val") and len(t.uint64_val) > 0:
          retval = _np.array(t.uint64_val, dtype=_TF_TO_NP[t.dtype])
  
      if not t.tensor_shape.unknown_rank and len(shape) == 0:
          retobj = typ()
          if retval is not None:
              retobj.val = retval[0]
      else:
          rettype = types.tensor(typ, tuple(shape))
          retobj = rettype()
          retobj.shape = shape
          if retval is not None:
              retobj.val = retval
  
      return retobj
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/tensorflow/parse.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  from coremltools.converters.mil.mil import types
  from tensorflow.core.framework.types_pb2 import DataType
  from tensorflow.python.framework.dtypes import _TF_TO_NP
  import logging
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: parse_tensor(t) and returns: retobj