def _parse_tensor_info_proto(tensor_info):
  """Returns a ParsedTensorInfo instance from a TensorInfo proto."""
  encoding = tensor_info.WhichOneof("encoding")
  dtype = tf.DType(tensor_info.dtype)
  shape = tf.TensorShape(tensor_info.tensor_shape)
  if encoding == "name":
    return ParsedTensorInfo(dtype=dtype, shape=shape, is_sparse=False)
  elif encoding == "coo_sparse":
    return ParsedTensorInfo(dtype=dtype, shape=shape, is_sparse=True)
  else:
    raise ValueError("Unsupported TensorInfo encoding %r" % encoding)
Returns a ParsedTensorInfo instance from a TensorInfo proto.