class_docstr: Class to store batched alignments (logits, labels, frame_confidence).
  Size is different from hypotheses, since blank outputs are preserved
class_docstr_tok: ["Class","to","store","batched","alignments","(","logits",",","labels",",","frame_confidence",")",".","Size","is","different","from","hypotheses",",","since","blank","outputs","are","preserved"]
docstr: Args:
      batch_size: batch size for hypotheses
      logits_dim: dimension for logits
      init_length: initial estimate for the lengths of flatten alignments
      device: device for storing data
      float_dtype: expected logits/confidence data type
      store_alignments: if alignments should be stored
      store_frame_confidence: if frame confidence should be stored
docstr_tok: ["Args",":","batch_size",":","batch","size","for","hypotheses","logits_dim",":","dimension","for","logits","init_length",":","initial","estimate","for","the","lengths","of","flatten","alignments","device",":","device","for","storing","data","float_dtype",":","expected","logits\/confidence","data","type","store_alignments",":","if","alignments","should","be","stored","store_frame_confidence",":","if","frame","confidence","should","be","stored"]
code: def __init__(
      self,
      batch_size: int,
      logits_dim: int,
      init_length: int,
      device: Optional[torch.device] = None,
      float_dtype: Optional[torch.dtype] = None,
      store_alignments: bool = True,
      store_frame_confidence: bool = False,
  ):
      """
  
      Args:
          batch_size: batch size for hypotheses
          logits_dim: dimension for logits
          init_length: initial estimate for the lengths of flatten alignments
          device: device for storing data
          float_dtype: expected logits/confidence data type
          store_alignments: if alignments should be stored
          store_frame_confidence: if frame confidence should be stored
      """
      if init_length <= 0:
          raise ValueError(
              f"init_length must be > 0, got {init_length}"
          )
      if batch_size <= 0:
          raise ValueError(f"batch_size must be > 0, got {batch_size}")
      self.with_frame_confidence = store_frame_confidence
      self.with_alignments = store_alignments
      self._max_length = init_length
  
      # tensor to store observed timesteps (for alignments / confidence scores)
      self.timesteps = torch.zeros(
          (batch_size, self._max_length),
          device=device,
          dtype=torch.long,
      )
      # current lengths of the utterances (alignments)
      self.current_lengths = torch.zeros(
          batch_size, device=device, dtype=torch.long
      )
  
      if self.with_alignments:
          # logits and labels; labels can contain <blank>, different from BatchedHyps
          self.logits = torch.zeros(
              (batch_size, self._max_length, logits_dim),
              device=device,
              dtype=float_dtype,
          )
          self.labels = torch.zeros(
              (batch_size, self._max_length),
              device=device,
              dtype=torch.long,
          )
      else:
          self.logits = None
          self.labels = None
  
      if self.with_frame_confidence:
          # tensor to store frame confidence
          self.frame_confidence = torch.zeros(
              (batch_size, self._max_length),
              device=device,
              dtype=float_dtype,
          )
      else:
          self.frame_confidence = None
  
file_path: NeMo/nemo/collections/asr/parts/utils/rnnt_utils.py
imports: from dataclasses import dataclass, field
  from typing import Any, Dict, List, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 1 to create a new BatchedAlignments object  with example: obj = BatchedAlignments(batch_size, logits_dim, init_length, device, float_dtype, store_alignments, store_frame_confidence)