code: def translate_generic_op(
      op, parameters, blob_writer, literal_params=[]
  ):
      inputs = {}
      for param_name, vars in op.inputs.items():
          if param_name.startswith("_"):
              continue
          if not isinstance(vars, (list, tuple)):
              vars = [vars]
  
          arguments = []
          for _var in vars:
              binding = pm.Argument.Binding()
              # use const value literals if requested
              if param_name in literal_params:
                  binding.value.CopyFrom(create_immediate_value(_var))
              else:
                  binding.name = _var.name
              arguments.append(binding)
  
          args = pm.Argument()
          args.arguments.extend(arguments)
          inputs[param_name] = args
  
      outputs = [
          pm.NamedValueType(
              name=v.name, type=types_to_proto(v.sym_type)
          )
          for v in op.outputs
      ]
      blocks = None
      if len(op.blocks) > 0:
          blocks = [
              create_block(b, parameters, blob_writer)
              for b in op.blocks
          ]
  
      op_type = op.op_type
      attr_dict = {}
      if op.op_type in SSAOpRegistry.custom_ops:
          op_type = "custom_layer"
          class_name = op.bindings.get("class_name", op.name)
          input_order = op.bindings.get("input_order", [])
          parameters = op.bindings.get("parameters", [])
          weights = op.bindings.get("weights", [])
          description = op.bindings.get("description", "")
  
          attr_dict["name"] = create_scalar_value(op.name)
          attr_dict["class_name"] = create_scalar_value(class_name)
          attr_dict["input_order"] = create_list_scalarvalue(
              input_order, str
          )
          attr_dict["parameters"] = create_list_scalarvalue(
              parameters, str
          )
          attr_dict["weights"] = create_list_scalarvalue(weights, str)
          attr_dict["description"] = create_scalar_value(description)
  
      attr_dict["name"] = create_scalar_value(op.name)
  
      return pm.Operation(
          type=op_type,
          blocks=blocks,
          inputs=inputs,
          attributes=attr_dict,
          outputs=outputs,
      )
  
imports: import os
  import warnings
  from typing import Optional
  import numpy
  from coremltools import _OPSET, _SPECIFICATION_VERSION_IOS_15
  from coremltools import _logger
  from coremltools.converters.mil.backend.backend_helper import _get_probability_var_for_classifier
  from coremltools.converters.mil.backend.mil.helper import cast_to_framework_io_dtype, create_file_value, create_immediate_value, create_list_scalarvalue, create_scalar_value, types_to_proto
  from coremltools.converters.mil.backend.nn.load import _set_optional_inputs
  from coremltools.converters.mil.input_types import EnumeratedShapes, ImageType, RangeDim, TensorType
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Function, Program, mil_list, types
  from coremltools.converters.mil.mil.ops.registry import SSAOpRegistry
  from coremltools.converters.mil.mil.types.symbolic import any_symbolic, any_variadic, is_symbolic
  from coremltools.models.neural_network.flexible_shape_utils import NeuralNetworkImageSize, NeuralNetworkImageSizeRange, add_enumerated_image_sizes, add_multiarray_ndshape_enumeration, set_multiarray_ndshape_range, update_image_size_range
  from coremltools.models.utils import _WEIGHTS_FILE_NAME
  from coremltools.proto import FeatureTypes_pb2
  from coremltools.proto import MIL_pb2
  from coremltools.proto import Model_pb2
  from ..backend_helper import _get_colorspace_enum, _validate_image_input_output_shapes
label_desc: Use image node_id 4 for calling a global function with example usage: translate_generic_op(op, parameters, blob_writer, literal_params) and returns: pm