code: def test_linear_quant_batchedmatmul_5bit(self):
      W = np.zeros((2, 3), dtype=np.uint8)
      W[0, :] = [31, 20, 11]
      W[1, :] = [1, 0, 8]
      quant_scale = np.reshape(np.array([10.0, 2.0, 3.0]), (1, 3))
      quant_bias = np.reshape(np.array([-2.0, -10.0, 6.0]), (1, 3))
      W_unquantized = np.broadcast_to(
          quant_scale, (2, 3)
      ) * W + np.broadcast_to(quant_bias, (2, 3))
      bias = np.array([1.0, 2.0, 3.0])
  
      input_features = [("data", datatypes.Array(2, 2))]
      output_features = [("out", None)]
      builder = NeuralNetworkBuilder(
          input_features,
          output_features,
          disable_rank5_shape_mapping=True,
      )
      builder.add_batched_mat_mul(
          name="batched_matmul",
          input_names=["data"],
          output_name="out",
          weight_matrix_rows=2,
          weight_matrix_columns=3,
          W=_convert_array_to_nbit_quantized_bytes(
              W.flatten(), 5
          ).tobytes(),
          bias=bias,
          is_quantized_weight=True,
          quantization_type="linear",
          nbits=5,
          quant_scale=quant_scale.flatten(),
          quant_bias=quant_bias.flatten(),
      )
      mlmodel = MLModel(
          builder.spec, compute_units=ComputeUnit.CPU_ONLY
      )
      data = np.zeros((2, 2), dtype=np.float32)
      data[0, :] = [5, 6]
      data[1, :] = [10, 12]
      data_dict = {"data": data}
      out = mlmodel.predict(data_dict)["out"]
      expected_out = np.matmul(data, W_unquantized) + bias
      self.assertTrue(out.shape == expected_out.shape)
      self.assertTrue(
          np.allclose(out.flatten(), expected_out.flatten())
      )
  
imports: import numpy
  import pytest
  import unittest
  import coremltools
  from coremltools import ComputeUnit
  from coremltools.converters.mil.mil.types.type_mapping import np_val_to_py_type
  from coremltools.models import MLModel, datatypes
  from coremltools.models.neural_network import NeuralNetworkBuilder
  from coremltools.models.neural_network.quantization_utils import _convert_array_to_nbit_quantized_bytes, quantize_weights
  from coremltools.models.utils import _is_macos, _macos_version
label_desc: Use image node_id 1 for calling the BasicNumericCorrectnessTest_1015NewLayers obj's underlying member method code with example usage: obj.test_linear_quant_batchedmatmul_5bit() without return types