code: def convert_to_mlmodel(model_spec, tensor_inputs, backend="nn_proto"):
      def _convert_to_inputtype(inputs):
          if isinstance(inputs, list):
              return [_convert_to_inputtype(x) for x in inputs]
          elif isinstance(inputs, tuple):
              return tuple([_convert_to_inputtype(x) for x in inputs])
          elif isinstance(inputs, torch.Tensor):
              return TensorType(shape=inputs.shape)
          else:
              raise ValueError(
                  "Unable to parse type {} into InputType.".format(
                      type(inputs)
                  )
              )
  
      inputs = list(_convert_to_inputtype(tensor_inputs))
      proto = _converter._convert(
          model_spec,
          inputs=inputs,
          convert_to=backend,
          convert_from="torch",
      )
      return MLModel(proto, useCPUOnly=True)
  
imports: import numpy
  import torch
  import torch.nn
  from six import string_types
  from coremltools import TensorType
  from coremltools.converters.mil.testing_reqs import _converter
  from coremltools.models import MLModel
  from coremltools._deps import _IS_MACOS
label_desc: Use image node_id 3 for calling a global function with example usage: convert_to_mlmodel(model_spec, tensor_inputs, backend) and returns: MLModel, unknown, tuple, TensorType