code: def get_batch_variables(
      manifest_lines_batch,
      model,
      separator,
      align_using_pred_text,
      audio_filepath_parts_in_utt_id,
      output_timestep_duration,
      simulate_cache_aware_streaming=False,
      use_buffered_chunked_streaming=False,
      buffered_chunk_params={},
  ):
      """
      Returns:
          log_probs, y, T, U (y and U are s.t. every other token is a blank) - these are the tensors we will need
              during Viterbi decoding.
          utt_obj_batch: a list of Utterance objects for every utterance in the batch.
          output_timestep_duration: a float indicating the duration of a single output timestep from
              the ASR Model.
      """
  
      # get hypotheses by calling 'transcribe'
      # we will use the output log_probs, the duration of the log_probs,
      # and (optionally) the predicted ASR text from the hypotheses
      audio_filepaths_batch = [
          line["audio_filepath"] for line in manifest_lines_batch
      ]
      B = len(audio_filepaths_batch)
      log_probs_list_batch = []
      T_list_batch = []
      pred_text_batch = []
  
      if not use_buffered_chunked_streaming:
          if not simulate_cache_aware_streaming:
              with torch.no_grad():
                  hypotheses = model.transcribe(
                      audio_filepaths_batch,
                      return_hypotheses=True,
                      batch_size=B,
                  )
          else:
              with torch.no_grad():
                  hypotheses = (
                      model.transcribe_simulate_cache_aware_streaming(
                          audio_filepaths_batch,
                          return_hypotheses=True,
                          batch_size=B,
                      )
                  )
  
          # if hypotheses form a tuple (from Hybrid model), extract just "best" hypothesis
          if type(hypotheses) == tuple and len(hypotheses) == 2:
              hypotheses = hypotheses[0]
  
          for hypothesis in hypotheses:
              log_probs_list_batch.append(hypothesis.y_sequence)
              T_list_batch.append(hypothesis.y_sequence.shape[0])
              pred_text_batch.append(hypothesis.text)
      else:
          delay = buffered_chunk_params["delay"]
          model_stride_in_secs = buffered_chunk_params[
              "model_stride_in_secs"
          ]
          tokens_per_chunk = buffered_chunk_params["tokens_per_chunk"]
          for l in tqdm(audio_filepaths_batch, desc="Sample:"):
              model.reset()
              model.read_audio_file(l, delay, model_stride_in_secs)
              hyp, logits = model.transcribe(
                  tokens_per_chunk, delay, keep_logits=True
              )
              log_probs_list_batch.append(logits)
              T_list_batch.append(logits.shape[0])
              pred_text_batch.append(hyp)
  
      # we loop over every line in the manifest that is in our current batch,
      # and record the y (list of tokens, including blanks), U (list of lengths of y) and
      # token_info_batch, word_info_batch, segment_info_batch
      y_list_batch = []
      U_list_batch = []
      utt_obj_batch = []
  
      for i_line, line in enumerate(manifest_lines_batch):
          if align_using_pred_text:
              gt_text_for_alignment = " ".join(
                  pred_text_batch[i_line].split()
              )
          else:
              gt_text_for_alignment = line["text"]
          utt_obj = get_utt_obj(
              gt_text_for_alignment,
              model,
              separator,
              T_list_batch[i_line],
              audio_filepaths_batch[i_line],
              _get_utt_id(
                  audio_filepaths_batch[i_line],
                  audio_filepath_parts_in_utt_id,
              ),
          )
  
          # update utt_obj.pred_text or utt_obj.text
          if align_using_pred_text:
              utt_obj.pred_text = pred_text_batch[i_line]
              if len(utt_obj.pred_text) == 0:
                  logging.info(
                      f"'pred_text' of utterance {utt_obj.utt_id} is empty - we will not generate"
                      " any output alignment files for this utterance"
                  )
              if "text" in line:
                  utt_obj.text = line[
                      "text"
                  ]  # keep the text as we will save it in the output manifest
          else:
              utt_obj.text = line["text"]
              if len(utt_obj.text) == 0:
                  logging.info(
                      f"'text' of utterance {utt_obj.utt_id} is empty - we will not generate"
                      " any output alignment files for this utterance"
                  )
  
          y_list_batch.append(utt_obj.token_ids_with_blanks)
          U_list_batch.append(len(utt_obj.token_ids_with_blanks))
          utt_obj_batch.append(utt_obj)
  
      # turn log_probs, y, T, U into dense tensors for fast computation during Viterbi decoding
      T_max = max(T_list_batch)
      U_max = max(U_list_batch)
      #  V = the number of tokens in the vocabulary + 1 for the blank token.
      if hasattr(model, "tokenizer"):
          V = len(model.tokenizer.vocab) + 1
      else:
          V = len(model.decoder.vocabulary) + 1
      T_batch = torch.tensor(T_list_batch)
      U_batch = torch.tensor(U_list_batch)
  
      # make log_probs_batch tensor of shape (B x T_max x V)
      log_probs_batch = V_NEGATIVE_NUM * torch.ones((B, T_max, V))
      for b, log_probs_utt in enumerate(log_probs_list_batch):
          t = log_probs_utt.shape[0]
          log_probs_batch[b, :t, :] = log_probs_utt
  
      # make y tensor of shape (B x U_max)
      # populate it initially with all 'V' numbers so that the 'V's will remain in the areas that
      # are 'padding'. This will be useful for when we make 'log_probs_reorderd' during Viterbi decoding
      # in a different function.
      y_batch = V * torch.ones((B, U_max), dtype=torch.int64)
      for b, y_utt in enumerate(y_list_batch):
          U_utt = U_batch[b]
          y_batch[b, :U_utt] = torch.tensor(y_utt)
  
      # calculate output_timestep_duration if it is None
      if output_timestep_duration is None:
          if not "window_stride" in model.cfg.preprocessor:
              raise ValueError(
                  "Don't have attribute 'window_stride' in 'model.cfg.preprocessor' => cannot calculate "
                  " model_downsample_factor => stopping process"
              )
  
          if not "sample_rate" in model.cfg.preprocessor:
              raise ValueError(
                  "Don't have attribute 'sample_rate' in 'model.cfg.preprocessor' => cannot calculate start "
                  " and end time of segments => stopping process"
              )
  
          with sf.SoundFile(audio_filepaths_batch[0]) as f:
              audio_dur = f.frames / f.samplerate
          n_input_frames = (
              audio_dur / model.cfg.preprocessor.window_stride
          )
          model_downsample_factor = round(
              n_input_frames / int(T_batch[0])
          )
  
          output_timestep_duration = (
              model.preprocessor.featurizer.hop_length
              * model_downsample_factor
              / model.cfg.preprocessor.sample_rate
          )
  
          logging.info(
              f"Calculated that the model downsample factor is {model_downsample_factor}"
              f" and therefore the ASR model output timestep duration is {output_timestep_duration}"
              " -- will use this for all batches"
          )
  
      return (
          log_probs_batch,
          y_batch,
          T_batch,
          U_batch,
          utt_obj_batch,
          output_timestep_duration,
      )
  
imports: import json
  from dataclasses import dataclass, field
  from pathlib import Path
  from typing import List, Union
  import soundfile
  import torch
  from tqdm.auto import tqdm
  from utils.constants import BLANK_TOKEN, SPACE_TOKEN, V_NEGATIVE_NUM
  from nemo.utils import logging
label_desc: Use image node_id 11 for calling a global function with example usage: get_batch_variables(manifest_lines_batch, model, separator, align_using_pred_text, audio_filepath_parts_in_utt_id, output_timestep_duration, simulate_cache_aware_streaming, use_buffered_chunked_streaming, buffered_chunk_params) and returns: log_probs_batch,  y_batch,  T_batch,  U_batch,  utt_obj_batch,  output_timestep_duration