code: def test_pack_biases():
      test_vecs = [
          {
              # Stimulus
              "bias_length": 3,
              "ifm_scale": np.single(1.11111111),
              "ifm_dtype": np.uint8,
              "weight_scales": np.array(
                  [
                      np.single(0.91111111),
                      np.single(1.01111111),
                      np.single(1.11111111),
                  ]
              ),
              "ofm_scale": np.single(1.2),
              "is_activation_tanh_or_sigmoid": False,
              # Reference outputs
              "hw_scales": (1811663288, 2010504240, 1104672703),
              "hw_shifts": (31, 31, 30),
          },
          {
              # Stimulus
              "bias_length": 3,
              "ifm_scale": np.single(1.11111111),
              "ifm_dtype": np.int8,
              "weight_scales": np.array(
                  [
                      np.single(0.91111111),
                      np.single(1.01111111),
                      np.single(1.11111111),
                  ]
              ),
              "ofm_scale": np.single(1.2),
              "is_activation_tanh_or_sigmoid": False,
              # Reference outputs
              "hw_scales": (1811663185, 2010504312, 1104672720),
              "hw_shifts": (31, 31, 30),
          },
          {
              # Stimulus
              "bias_length": 3,
              "ifm_scale": np.single(1.11111111),
              "ifm_dtype": np.int16,
              "weight_scales": np.array(
                  [
                      np.single(0.91111111),
                      np.single(1.01111111),
                      np.single(1.11111111),
                  ]
              ),
              "ofm_scale": np.single(1.2),
              "is_activation_tanh_or_sigmoid": False,
              # Reference outputs
              "hw_scales": (27644, 30678, 16856),
              "hw_shifts": (15, 15, 14),
          },
      ]
  
      def verify(test_vec, mock_obj, packed_biases):
          assert mock_obj
          for idx, val in enumerate(test_vec["bias_values"]):
              assert val == mock_obj.call_args_list[idx][0][0]
              assert (
                  test_vec["hw_scales"][idx]
                  == mock_obj.call_args_list[idx][0][1]
              )
              assert (
                  test_vec["hw_shifts"][idx]
                  == mock_obj.call_args_list[idx][0][2]
              )
  
      def create_mock(test_vec):
          with patch(
              "ethosu.vela.api.npu_encode_bias"
          ) as mock_npu_encode_bias:
              mock_npu_encode_bias.return_value = bytearray(10)
              ifm_dtype = test_vec["ifm_dtype"]
              max = np.iinfo(ifm_dtype).max
              min = np.iinfo(ifm_dtype).min
              # tvm will always create biases in int32
              biases = np.random.randint(
                  min, max, test_vec["bias_length"], np.int32
              )
              packed_biases = vela_api.pack_biases(
                  biases=biases,
                  ifm_scale=test_vec["ifm_scale"],
                  ifm_dtype=test_vec["ifm_dtype"],
                  weight_scales=test_vec["weight_scales"],
                  ofm_scale=test_vec["ofm_scale"],
                  is_activation_tanh_or_sigmoid=test_vec[
                      "is_activation_tanh_or_sigmoid"
                  ],
              )
              test_vec["bias_values"] = biases
              return mock_npu_encode_bias, packed_biases
          return None
  
      for _test_vec in test_vecs:
          mock_obj, packed_biases = create_mock(_test_vec)
          verify(_test_vec, mock_obj, packed_biases)
  
imports: import pytest
  import numpy
  from ethosu.vela import api
  from unittest.mock import patch
  import tvm
  from tvm.script import tir
  from tvm.tir import stmt_functor
  from tvm.relay.backend.contrib.ethosu import vela_api
  import tvm.relay.backend.contrib.ethosu.tir_to_cs_translator
label_desc: Use image node_id 4 for calling a global function with example usage: test_pack_biases() and returns: None, mock_npu_encode_bias,  packed_biases