docstr: Helper class to compute the Transducer Loss on CPU.
  
  Args:
      minibatch: Size of the minibatch b.
      maxT: The maximum possible acoustic sequence length. Represents T in the logprobs tensor.
      maxU: The maximum possible target sequence length. Represents U in the logprobs tensor.
      alphabet_size: The vocabulary dimension V+1 (inclusive of RNNT blank).
      workspace: An allocated chunk of memory that will be sliced off and reshaped into required
          blocks used as working memory.
      blank: Index of the RNNT blank token in the vocabulary. Generally the first or last token in the vocab.
      fastemit_lambda: Float scaling factor for FastEmit regularization. Refer to
          FastEmit: Low-latency Streaming ASR with Sequence-level Emission Regularization.
      clamp: Float value. When set to value >= 0.0, will clamp the gradient to [-clamp, clamp].
      num_threads: Number of OMP threads to launch.
      batch_first: Bool that decides if batch dimension is first or third.
docstr_tok: ["Helper","class","to","compute","the","Transducer","Loss","on","CPU",".","Args",":","minibatch",":","Size","of","the","minibatch","b.","maxT",":","The","maximum","possible","acoustic","sequence","length",".","Represents","T","in","the","logprobs","tensor",".","maxU",":","The","maximum","possible","target","sequence","length",".","Represents","U","in","the","logprobs","tensor",".","alphabet_size",":","The","vocabulary","dimension","V+1","(","inclusive","of","RNNT","blank",")",".","workspace",":","An","allocated","chunk","of","memory","that","will","be","sliced","off","and","reshaped","into","required","blocks","used","as","working","memory",".","blank",":","Index","of","the","RNNT","blank","token","in","the","vocabulary",".","Generally","the","first","or","last","token","in","the","vocab",".","fastemit_lambda",":","Float","scaling","factor","for","FastEmit","regularization",".","Refer","to","FastEmit",":","Low-latency","Streaming","ASR","with","Sequence-level","Emission","Regularization",".","clamp",":","Float","value",".","When","set","to","value",">","=","0.0",",","will","clamp","the","gradient","to","[","-clamp",",","clamp","]",".","num_threads",":","Number","of","OMP","threads","to","launch",".","batch_first",":","Bool","that","decides","if","batch","dimension","is","first","or","third","."]
code: def __init__(
      self,
      minibatch: int,
      maxT: int,
      maxU: int,
      alphabet_size: int,
      workspace: torch.Tensor,
      blank: int,
      fastemit_lambda: float,
      clamp: float,
      num_threads: int,
      batch_first: bool,
  ):
      """
      Helper class to compute the Transducer Loss on CPU.
  
      Args:
          minibatch: Size of the minibatch b.
          maxT: The maximum possible acoustic sequence length. Represents T in the logprobs tensor.
          maxU: The maximum possible target sequence length. Represents U in the logprobs tensor.
          alphabet_size: The vocabulary dimension V+1 (inclusive of RNNT blank).
          workspace: An allocated chunk of memory that will be sliced off and reshaped into required
              blocks used as working memory.
          blank: Index of the RNNT blank token in the vocabulary. Generally the first or last token in the vocab.
          fastemit_lambda: Float scaling factor for FastEmit regularization. Refer to
              FastEmit: Low-latency Streaming ASR with Sequence-level Emission Regularization.
          clamp: Float value. When set to value >= 0.0, will clamp the gradient to [-clamp, clamp].
          num_threads: Number of OMP threads to launch.
          batch_first: Bool that decides if batch dimension is first or third.
      """
      self.minibatch_ = minibatch
      self.maxT_ = maxT
      self.maxU_ = maxU
      self.alphabet_size_ = alphabet_size
      self.workspace = workspace  # a flat vector of floatX numbers that represents allocated memory slices
      self.blank_ = blank
      self.fastemit_lambda_ = fastemit_lambda
      self.clamp_ = abs(clamp)
      self.num_threads_ = num_threads
      self.batch_first = batch_first
  
      _torch_num_threads = torch.get_num_threads()
      if num_threads > 0:
          numba.set_num_threads(
              min(multiprocessing.cpu_count(), num_threads)
          )
          self.num_threads_ = numba.get_num_threads()
      else:
          self.num_threads_ = numba.get_num_threads()
      torch.set_num_threads(_torch_num_threads)
  
imports: import math
  import multiprocessing
  from typing import Optional
  import numba
  import torch
  from torch.autograd import Function
  from nemo.collections.asr.parts.numba.rnnt_loss.utils import global_constants
label_desc: Use image node_id 1 to create a new CPURNNT object  with example: obj = CPURNNT(minibatch, maxT, maxU, alphabet_size, workspace, blank, fastemit_lambda, clamp, num_threads, batch_first)