class_docstr: Encoder decoder class for speaker label models.
  Model class creates training, validation methods for setting up data
  performing model forward pass.
  Expects config dict for
      * preprocessor
      * Jasper/Quartznet Encoder
      * Speaker Decoder
class_docstr_tok: ["Encoder","decoder","class","for","speaker","label","models",".","Model","class","creates","training",",","validation","methods","for","setting","up","data","performing","model","forward","pass",".","Expects","config","dict","for","*","preprocessor","*","Jasper\/Quartznet","Encoder","*","Speaker","Decoder"]
docstr: Perform batch inference on EncDecSpeakerLabelModel.
  To perform inference on single audio file, once can use infer_model, get_label or get_embedding
  
  To map predicted labels, one can do
      `arg_values = logits.argmax(axis=1)`
      `pred_labels = list(map(lambda t : trained_labels[t], arg_values))`
  
  Args:
      manifest_filepath: Path to manifest file
      batch_size: batch size to perform batch inference
      sample_rate: sample rate of audio files in manifest file
      device: compute device to perform operations.
  
  Returns:
      The variables below all follow the audio file order in the manifest file.
      embs: embeddings of files provided in manifest file
      logits: logits of final layer of EncDecSpeakerLabel Model
      gt_labels: labels from manifest file (needed for speaker enrollment and testing)
      trained_labels: Classification labels sorted in the order that they are mapped by the trained model
code: def batch_inference(
      self,
      manifest_filepath,
      batch_size=32,
      sample_rate=16000,
      device="cuda",
  ):
      """
      Perform batch inference on EncDecSpeakerLabelModel.
      To perform inference on single audio file, once can use infer_model, get_label or get_embedding
  
      To map predicted labels, one can do
          `arg_values = logits.argmax(axis=1)`
          `pred_labels = list(map(lambda t : trained_labels[t], arg_values))`
  
      Args:
          manifest_filepath: Path to manifest file
          batch_size: batch size to perform batch inference
          sample_rate: sample rate of audio files in manifest file
          device: compute device to perform operations.
  
      Returns:
          The variables below all follow the audio file order in the manifest file.
          embs: embeddings of files provided in manifest file
          logits: logits of final layer of EncDecSpeakerLabel Model
          gt_labels: labels from manifest file (needed for speaker enrollment and testing)
          trained_labels: Classification labels sorted in the order that they are mapped by the trained model
  
      """
      mode = self.training
      self.freeze()
      self.eval()
      self.to(device)
      trained_labels = self._cfg["train_ds"]["labels"]
      if trained_labels is not None:
          trained_labels = list(trained_labels)
  
      featurizer = WaveformFeaturizer(sample_rate=sample_rate)
  
      dataset = AudioToSpeechLabelDataset(
          manifest_filepath=manifest_filepath,
          labels=None,
          featurizer=featurizer,
      )
  
      dataloader = torch.utils.data.DataLoader(
          dataset=dataset,
          batch_size=batch_size,
          collate_fn=dataset.fixed_seq_collate_fn,
      )
  
      logits = []
      embs = []
      gt_labels = []
  
      for test_batch in tqdm(dataloader):
          if device == "cuda":
              test_batch = [x.to(device) for x in test_batch]
          audio_signal, audio_signal_len, labels, _ = test_batch
          logit, emb = self.forward(
              input_signal=audio_signal,
              input_signal_length=audio_signal_len,
          )
  
          logits.extend(logit.cpu().numpy())
          gt_labels.extend(labels.cpu().numpy())
          embs.extend(emb.cpu().numpy())
  
      gt_labels = list(map(lambda t: dataset.id2label[t], gt_labels))
  
      self.train(mode=mode)
      if mode is True:
          self.unfreeze()
  
      logits, embs, gt_labels = (
          np.asarray(logits),
          np.asarray(embs),
          np.asarray(gt_labels),
      )
  
      return embs, logits, gt_labels, trained_labels
  
imports: import copy
  import itertools
  from collections import Counter
  from math import ceil
  from typing import Dict, List, Optional, Union
  import librosa
  import numpy
  import soundfile
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig, OmegaConf, open_dict
  from pytorch_lightning import Trainer
  from torchmetrics import Accuracy
  from tqdm import tqdm
  from nemo.collections.asr.data.audio_to_label import AudioToSpeechLabelDataset, cache_datastore_manifests
  from nemo.collections.asr.data.audio_to_label_dataset import get_concat_tarred_speech_label_dataset, get_tarred_speech_label_dataset
  from nemo.collections.asr.data.audio_to_text_dataset import convert_to_config_list
  from nemo.collections.asr.models.asr_model import ExportableEncDecModel
  from nemo.collections.asr.parts.preprocessing.features import WaveformFeaturizer
  from nemo.collections.asr.parts.preprocessing.perturb import process_augmentations
  from nemo.collections.common.metrics import TopKClassificationAccuracy
  from nemo.collections.common.parts.preprocessing.collections import ASRSpeechLabel
  from nemo.core.classes import ModelPT
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types import *
  from nemo.utils import logging
label_desc: Use image node_id 25 for calling the EncDecSpeakerLabelModel obj's underlying member method code with example usage: obj.batch_inference(manifest_filepath, batch_size, sample_rate, device) and returns: embs,  logits,  gt_labels,  trained_labels