code: def test_tf(
      self,
      compute_unit,
      backend,
      transpose_a,
      transpose_b,
      a_is_sparse,
      b_is_sparse,
      b_is_const,
  ):
      if backend[0] == "mlprogram":
          pytest.skip(
              "Custom layer not supported with ML Program backend"
          )
  
      rank = 2
      input_shape = (
          list(np.random.randint(low=3, high=100, size=1)) * rank
      )
      if b_is_const:
  
          @make_tf_graph([input_shape])
          def build_model(x):
              ref = tf.compat.v1.sparse_matmul(
                  x,
                  random_gen(input_shape),
                  transpose_a=transpose_a,
                  transpose_b=transpose_b,
                  a_is_sparse=a_is_sparse,
                  b_is_sparse=b_is_sparse,
              )
              return ref
  
          input_values = [random_gen(input_shape, -1.0, 1.0)]
      else:
  
          @make_tf_graph([input_shape, input_shape])
          def build_model(x, y):
              ref = tf.compat.v1.sparse_matmul(
                  x,
                  y,
                  transpose_a=transpose_a,
                  transpose_b=transpose_b,
                  a_is_sparse=a_is_sparse,
                  b_is_sparse=b_is_sparse,
              )
              return ref
  
          input_values = [
              random_gen(input_shape, -1.0, 1.0),
              random_gen(input_shape, -1.0, 1.0),
          ]
  
      model, inputs, outputs = build_model
      input_dict = dict(zip(inputs, input_values))
      spec, _, _, _, _, _ = TensorFlowBaseTest.run_compare_tf(
          model,
          input_dict,
          outputs,
          compute_unit=compute_unit,
          frontend_only=True,
          backend=backend,
      )
  
      layers = spec.neuralNetwork.layers
      assert layers[-1].custom is not None, "Expecting a custom layer"
      assert (
          "SparseMatMul" == layers[-1].custom.className
      ), "Custom Layer class name mismatch"
      assert (
          transpose_a
          == layers[-1].custom.parameters["transpose_x"].boolValue
      ), "Incorrect parameter value k"
      assert (
          transpose_b
          == layers[-1].custom.parameters["transpose_y"].boolValue
      ), "Incorrect parameter value k"
      assert (
          a_is_sparse
          == layers[-1].custom.parameters["x_is_sparse"].boolValue
      ), "Incorrect parameter value k"
      assert (
          b_is_sparse
          == layers[-1].custom.parameters["y_is_sparse"].boolValue
      ), "Incorrect parameter value k"
  
      assert len(layers) == 2 if b_is_const else len(layers) == 1
  
file_path: coremltools/coremltools/converters/mil/frontend/tensorflow/test/test_custom_ops.py
imports: import itertools
  import numpy
  import pytest
  from coremltools.converters.mil.frontend.tensorflow.test.testing_utils import TensorFlowBaseTest, make_tf_graph
  from coremltools.converters.mil.frontend.tensorflow.tf_op_registry import _TF_OPS_REGISTRY, register_tf_op
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Operation, types
  from coremltools.converters.mil.mil.input_type import DefaultInputs, InputSpec, TensorInputType
  from coremltools.converters.mil.mil.ops.defs._op_reqs import register_op
  from coremltools.converters.mil.mil.types.symbolic import is_symbolic
  from coremltools.converters.mil.testing_reqs import backends, compute_units
  from coremltools.converters.mil.testing_utils import random_gen
label_desc: Use image node_id 2 for calling the TestCustomMatMul obj's underlying member method code with example usage: obj.test_tf(compute_unit, backend, transpose_a, transpose_b, a_is_sparse, b_is_sparse, b_is_const) and returns: ref, ref