code: def get_rnnt_alignments(
      strategy: str, loop_labels: bool = True, location="cuda"
  ):
      cfg = OmegaConf.structured(
          TranscriptionConfig(pretrained_name=PRETRAINED_MODEL_NAME)
      )
      cfg.rnnt_decoding.confidence_cfg.preserve_frame_confidence = True
      cfg.rnnt_decoding.preserve_alignments = True
      cfg.rnnt_decoding.strategy = strategy
      if cfg.rnnt_decoding.strategy == "greedy_batch":
          cfg.rnnt_decoding.greedy.loop_labels = loop_labels
      cfg.dataset_manifest = TEST_DATA_PATH
      filepaths = prepare_audio_data(cfg)[0][
          :10
      ]  # selecting 10 files only
  
      model = setup_model(cfg, map_location=location)[0]
      model.change_decoding_strategy(cfg.rnnt_decoding)
  
      transcriptions = model.transcribe(
          paths2audio_files=filepaths,
          batch_size=cfg.batch_size,
          num_workers=cfg.num_workers,
          return_hypotheses=True,
          channel_selector=cfg.channel_selector,
      )[0]
  
      for transcription in transcriptions:
          for align_elem, frame_confidence in zip(
              transcription.alignments, transcription.frame_confidence
          ):
              assert len(align_elem) == len(
                  frame_confidence
              )  # frame confidences have to match alignments
              assert len(align_elem) > 0  # no empty alignments
              for idx, pred in enumerate(align_elem):
                  if idx < len(align_elem) - 1:
                      assert (
                          pred[1].item() != model.decoder.blank_idx
                      )  # all except last have to be non-blank
                  else:
                      assert (
                          pred[1].item() == model.decoder.blank_idx
                      )  # last one has to be blank
      return transcriptions
  
imports: import os
  import pytest
  from examples.asr.transcribe_speech import TranscriptionConfig
  from omegaconf import OmegaConf
  from nemo.collections.asr.parts.utils.transcribe_utils import prepare_audio_data, setup_model
label_desc: Use image node_id 1 for calling a global function with example usage: get_rnnt_alignments(strategy, loop_labels, location) and returns: transcriptions