code: def test_randomly_negate(
      mag_range, num_magnitude_bins, use_implicit_sign, const_mag
  ):
      batch_size = 64
  
      @augmentation(mag_range=mag_range, randomly_negate=True)
      def pass_through_mag(data, param):
          return param
  
      @pipeline_def(
          num_threads=4, device_id=0, batch_size=batch_size, seed=42
      )
      def pipeline():
          magnitude_bin = (
              const_mag
              if const_mag is not None
              else sample_info(
                  lambda info: info.idx_in_batch % num_magnitude_bins
              )
          )
          if not use_implicit_sign:
              magnitude_sign = sample_info(
                  lambda info: info.idx_in_batch % 2
              )
              magnitude_bin = signed_bin(magnitude_bin, magnitude_sign)
  
          return pass_through_mag(
              types.Constant(42),
              magnitude_bin=magnitude_bin,
              num_magnitude_bins=num_magnitude_bins,
          )
  
      if not use_implicit_sign:
          p = pipeline()
      else:
          warn_glob = "but unsigned `magnitude_bin` was passed to the augmentation call"
          with assert_warns(Warning, glob=warn_glob):
              p = pipeline()
      p.build()
      (magnitudes,) = p.run()
      magnitudes = [np.array(el) for el in magnitudes]
      if use_implicit_sign:
          # the implicit sign is random, just sanity check if
          # there are some positive and negative magnitudes
          assert any(el < 0 for el in magnitudes)
          assert any(el > 0 for el in magnitudes)
          magnitudes = [np.abs(el) for el in magnitudes]
  
      mag_sign = (
          None
          if use_implicit_sign
          else [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,
      )
      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 6 for calling a global function with example usage: test_randomly_negate(mag_range, num_magnitude_bins, use_implicit_sign, const_mag) and returns: param, pass_through_mag