code: def test_node_name_type_custom_functions(self):  # type: () -> None
      def convert_acos(builder, node, graph, err):
          params = NeuralNetwork_pb2.CustomLayerParams()
          params.className = node.op_type
          params.description = (
              "Custom layer that corresponds to the ONNX op {}".format(
                  node.op_type,
              )
          )
  
          builder.add_custom(
              name=node.name,
              input_names=node.inputs,
              output_names=node.outputs,
              custom_proto_spec=params,
          )
  
      def convert_topk_generic(builder, node, graph, err):
          params = NeuralNetwork_pb2.CustomLayerParams()
          params.className = node.op_type
          params.description = (
              "Custom layer that corresponds to the ONNX op {}".format(
                  node.op_type,
              )
          )
          params.parameters["axis"].intValue = node.attrs.get(
              "axis", -1
          )
          params.parameters["k"].intValue = node.attrs["k"]
  
          builder.add_custom(
              name=node.name,
              input_names=node.inputs,
              output_names=node.outputs,
              custom_proto_spec=params,
          )
  
      def convert_topk_node_specific(builder, node, graph, err):
          params = NeuralNetwork_pb2.CustomLayerParams()
          params.className = node.op_type
          params.description = (
              "Custom layer that corresponds to the ONNX op {}".format(
                  node.op_type,
              )
          )
          params.parameters["axis"].intValue = node.attrs.get(
              "axis", -1
          )
  
          builder.add_custom(
              name=node.name,
              input_names=node.inputs,
              output_names=node.outputs,
              custom_proto_spec=params,
          )
  
      onnx_model = _make_model_acos_exp_topk()
      coreml_model = convert(
          model=onnx_model,
          add_custom_layers=True,
          custom_conversion_functions={
              "Acos": convert_acos,
              "TopK": convert_topk_generic,
              "output_values_output_indices": convert_topk_node_specific,
          },
      )
  
      spec = coreml_model.get_spec()
      layers = spec.neuralNetwork.layers
      self.assertIsNotNone(layers[0].custom)
      self.assertIsNotNone(layers[2].custom)
      self.assertEqual("Acos", layers[0].custom.className)
      self.assertEqual("TopK", layers[2].custom.className)
      self.assertEqual(0, layers[2].custom.parameters["axis"].intValue)
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/onnx/_tests/test_custom_layers.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import unittest
  from coremltools._deps import _HAS_ONNX, MSG_ONNX_NOT_FOUND
  from coremltools.proto import NeuralNetwork_pb2
label_desc: Use image node_id 3 for calling the CustomLayerTest obj's underlying member method code with example usage: obj.test_node_name_type_custom_functions() without return types