code: def test_mag_to_param(
      mag_range, num_magnitude_bins, const_mag, dtype, param_device
  ):
      batch_size = 31
  
      def mag_to_param(magnitude):
          return np.array([magnitude, magnitude + 2, 42], dtype=dtype)
  
      @augmentation(
          mag_range=mag_range,
          randomly_negate=True,
          mag_to_param=mag_to_param,
          param_device=param_device,
      )
      def pass_through_mag(data, param):
          return param
  
      @pipeline_def(
          num_threads=4, device_id=0, batch_size=batch_size, seed=42
      )
      def pipeline():
          mag_sign = sample_info(lambda info: info.idx_in_batch % 2)
          magnitude_bin = (
              const_mag
              if const_mag is not None
              else sample_info(
                  lambda info: info.idx_in_batch % num_magnitude_bins
              )
          )
  
          return pass_through_mag(
              types.Constant(42),
              magnitude_bin=signed_bin(magnitude_bin, mag_sign),
              num_magnitude_bins=num_magnitude_bins,
          )
  
      p = pipeline()
      p.build()
      (magnitudes,) = p.run()
      if param_device == "cpu":
          assert isinstance(magnitudes, _tensors.TensorListCPU)
      else:
          assert isinstance(magnitudes, _tensors.TensorListGPU)
          magnitudes = magnitudes.as_cpu()
      magnitudes = [np.array(el) for el in magnitudes]
  
      mag_sign = [i % 2 for i in range(batch_size)]
      magnitude_bin = (
          [const_mag] * batch_size
          if const_mag is not None
          else [i % num_magnitude_bins for i in range(batch_size)]
      )
      ref_magnitudes = ref_param(
          mag_range,
          num_magnitude_bins,
          magnitude_bin,
          mag_signs_batch=mag_sign,
          mag_to_param=mag_to_param,
      )
      assert (
          np.array(magnitudes).dtype == np.array(ref_magnitudes).dtype
      )
      check_batch(magnitudes, ref_magnitudes, max_allowed_error=0)
  
imports: import numpy
  import nvidia.dali.tensors
  from nvidia.dali import pipeline_def, fn, types
  from nvidia.dali.auto_aug.core import augmentation, signed_bin
  from nvidia.dali.auto_aug.core._args import forbid_unused_kwargs
  from nose2.tools import params
  from test_utils import check_batch
  from nose_utils import assert_warns, assert_raises
label_desc: Use image node_id 8 for calling a global function with example usage: test_mag_to_param(mag_range, num_magnitude_bins, const_mag, dtype, param_device) and returns: np, param, pass_through_mag