code: def create_scalar_value(py_scalar):
      """
      Return TensorValue (since there's no ScalarValue)
      """
      # Create the "scalar" (rank 0) tensor
      builtin_type = type_to_builtin_type(type(py_scalar))
      value_type = create_valuetype_scalar(
          types_to_proto_primitive(builtin_type)
      )
      val = pm.Value(type=value_type)
      t_val = val.immediateValue.tensor
  
      # Set the tensor value
      t_field = _tensor_field_by_type(t_val, builtin_type)
      if builtin_type in IMMEDIATE_VALUE_TYPES_IN_BYTES:
          # Serialize to bytes because MIL read them from the "bytes" field in TensorValue.
          val.immediateValue.tensor.bytes.values = np_val_to_py_type(
              py_scalar
          )
      else:
          if builtin_type == types.str:
              py_scalar = py_scalar.encode("utf-8")
          t_field.append(np_val_to_py_type(py_scalar))
  
      return val
  
imports: import os
  import numpy
  import coremltools.proto.FeatureTypes_pb2
  import coremltools.proto.MIL_pb2
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.types import BUILTIN_TO_PROTO_TYPES, builtin_to_string, numpy_type_to_builtin_type, type_to_builtin_type
  from coremltools.converters.mil.mil.types.type_mapping import np_val_to_py_type
  from coremltools.models.utils import _WEIGHTS_DIR_NAME, _WEIGHTS_FILE_NAME
label_desc: Use image node_id 11 for calling a global function with example usage: create_scalar_value(py_scalar) and returns: val