code: def test_decoded_vs_generated():
      pipeline = DecoderPipeline()
      pipeline.build()
      idx = 0
      for iter in range(1):
          out = pipeline.run()
          for i in range(len(out[0])):
              plain = out[0].at(i)
              res = out[1].at(i)
              mix = out[2].at(i)[:, np.newaxis]
              res_mix = out[3].at(i)[:, np.newaxis]
  
              ref_len = [0, 0, 0, 0]
              ref_len[0] = lengths[idx]
              ref_len[1] = lengths[idx] * rate1 / rates[idx]
              ref_len[2] = lengths[idx]
              ref_len[3] = lengths[idx] * rate2 / rates[idx]
  
              ref0 = generate_waveforms(ref_len[0], freqs[idx]) * 32767
              ref1 = (
                  generate_waveforms(
                      ref_len[1], freqs[idx] * (rates[idx] / rate1)
                  )
                  * 32767
              )
              ref2 = generate_waveforms(ref_len[2], freqs[idx]) * 32767
              ref2 = ref2.mean(axis=1, keepdims=1)
              ref3 = generate_waveforms(
                  ref_len[3], freqs[idx] * (rates[idx] / rate2)
              )
              ref3 = ref3.mean(axis=1, keepdims=1)
  
              assert out[4].at(i) == rates[idx]
              assert out[5].at(i) == rate1
              assert out[6].at(i) == rates[idx]
              assert out[7].at(i) == rate2
  
              # just reading - allow only for rounding
              assert np.allclose(plain, ref0, rtol=0, atol=0.5)
              # resampling - allow for 1e-3 dynamic range error
              assert np.allclose(res, ref1, rtol=0, atol=32767 * 1e-3)
              # downmixing - allow for 2 bits of error
              # - one for quantization of channels, one for quantization of result
              assert np.allclose(mix, ref2, rtol=0, atol=2)
              # resampling with weird ratio - allow for 3e-3 dynamic range error
              assert np.allclose(res_mix, ref3, rtol=0, atol=3e-3)
  
              rosa_in1 = plain.astype(np.float32)
              rosa1 = rosa_resample(rosa_in1, rates[idx], rate1)
              rosa_in3 = rosa_in1 / 32767
              rosa3 = rosa_resample(
                  rosa_in3.mean(axis=1, keepdims=1), rates[idx], rate2
              )
  
              assert np.allclose(res, rosa1, rtol=0, atol=32767 * 1e-3)
              assert np.allclose(res_mix, rosa3, rtol=0, atol=3e-3)
  
              idx = (idx + 1) % len(names)
  
imports: from nvidia.dali import Pipeline, pipeline_def
  import nvidia.dali.fn
  import nvidia.dali.ops
  import nvidia.dali.types
  import scipy.io.wavfile
  import numpy
  import os
  from test_audio_decoder_utils import generate_waveforms, rosa_resample
  from test_utils import compare_pipelines, get_files
label_desc: Use image node_id 2 for calling a global function with example usage: test_decoded_vs_generated() without return types