code: def test_type_conversion():
      type_ranges = [
          (types.FLOAT, [-1, 1]),
          (types.UINT8, [0, 255]),
          (types.INT8, [-127, 127]),
          (types.UINT16, [0, 65535]),
          (types.INT16, [-32767, 32767]),
          (types.INT32, [-0x7FFFFFFF, 0x7FFFFFFF]),
          (types.UINT32, [0, 0xFFFFFFFF]),
      ]
  
      for src_type, src_range in type_ranges:
          i_lo, i_hi = src_range
          if i_lo == -i_hi:
              in_values = [i_lo, 0, i_hi]
          else:
              in_values = [
                  i_lo,
                  (i_lo + i_hi) // 2,
                  (i_lo + i_hi + 1) // 2,
                  i_hi,
              ]
  
          for dst_type, dst_range in type_ranges:
              o_lo, o_hi = dst_range
              if len(in_values) == 3:
                  if o_lo != -o_hi:
                      out_values = [
                          o_lo,
                          (o_hi + o_lo + 1) / 2,
                          o_hi,
                      ]  # rounding
                  else:
                      out_values = [o_lo, 0, o_hi]
              else:
                  out_values = [
                      o_lo,
                      o_lo
                      + (o_hi - o_lo) * in_values[1] / (i_hi - i_lo),
                      o_lo
                      + (o_hi - o_lo) * in_values[2] / (i_hi - i_lo),
                      o_hi,
                  ]
              if dst_type != types.FLOAT:
                  out_values = list(map(int, out_values))
              eps = (o_hi - o_lo) / 2**24 + (i_hi - i_lo) / 2**24
              print(src_type, in_values, dst_type, out_values)
  
              # the result will be halfway - add epsilon of 1
              if eps < 1 and (
                  o_lo != -o_hi
                  or (i_hi != i_lo and dst_type != types.FLOAT)
              ):
                  eps = 1
  
              for device in ("cpu", "gpu"):
                  yield _test_type_conversion, device, src_type, in_values, dst_type, out_values, eps
  
file_path: DALI/dali/test/python/operator_1/test_audio_resample.py
imports: import numpy
  import scipy.io.wavfile
  from nvidia.dali import fn, pipeline_def, types
  from test_audio_decoder_utils import generate_waveforms
  from test_utils import check_batch, dali_type_to_np, as_array
label_desc: Use image node_id 7 for calling a global function with example usage: test_type_conversion() without return types