code: def test_nemo_asr_reader_pad_last_batch():
      @pipeline_def(device_id=0, num_threads=4)
      def nemo_asr_pad_last_batch_pipe():
          audio = fn.readers.nemo_asr(
              manifest_filepaths=[nemo_asr_manifest],
              pad_last_batch=True,
              read_sample_rate=False,
              read_text=False,
          )
  
          return audio
  
      def _testimpl_nemo_asr_reader_pad_last_batch(batch_size):
          pipe = nemo_asr_pad_last_batch_pipe(batch_size=batch_size)
          pipe.build()
  
          dataset_len = len(names)
          assert (
              dataset_len % batch_size > 0
          )  # Checking that we need to pad
          sample_idx = 0
          for it in range(10):
              audio = pipe.run()[0]
              sample_idx = it * batch_size
              if sample_idx > dataset_len:
                  sample_idx = 0
              last_sample = None
              padded_sample = None
              for i in range(batch_size):
                  if sample_idx == dataset_len - 1:
                      last_sample = np.array(audio[i])
                  elif sample_idx >= dataset_len:
                      padded_sample = np.array(audio[i])
                      np.testing.assert_array_equal(
                          padded_sample, last_sample
                      )
                  sample_idx += 1
  
      # The manifest has 3 samples, of lengths 10000, 54321, 12345
  
      # With batch size 2, batches will contain lengths:
      # [10000, 54321], [12345, 12345], [10000, 54321], ...
      # This is meant to reproduce an error found when combining pad_last_sample=True,
      # using ShareData to replicate the last sample, and trying to resize to a bigger
      # buffer after ShareData.
      yield _testimpl_nemo_asr_reader_pad_last_batch, 2
  
      # Trying to catch race conditions (A lot of samples in the batch to be replicated)
      yield _testimpl_nemo_asr_reader_pad_last_batch, 128
  
imports: from nvidia.dali import Pipeline, pipeline_def
  from nvidia.dali import fn
  import nvidia.dali.types
  import scipy.io.wavfile
  import numpy
  import json
  import tempfile
  import os
  from test_audio_decoder_utils import generate_waveforms
  from test_utils import compare_pipelines
label_desc: Use image node_id 7 for calling a global function with example usage: test_nemo_asr_reader_pad_last_batch() and returns: audio