class_docstr: Base class for graph transducer losses.
  Implementation of the approach described in "Powerful and Extensible WFST Framework for RNN-Transducer Losses"
  https://ieeexplore.ieee.org/document/10096679
  
  Compose-Transducer: compose the unit (target text) and temporal schemas (graphs) into lattice.
      Subclass should implement `get_unit_schema` and `get_temporal_schema` methods.
  Grid-Transducer: construct the RNN-T lattice (grid) directly in code.
      Subclass should implement `get_grid` method.
docstr: Get batched lattice (grid or composed) for the batch of sequences.
  
  Args:
      logits_lengths: tensor with lengths of logits
      targets: tensor with target units
      target_lengths: tensor with lengths of targets
      vocab_size: vocab size (including blank)
  
  Returns:
      batched lattice - FsaVec (k2.Fsa)
docstr_tok: ["Get","batched","lattice","(","grid","or","composed",")","for","the","batch","of","sequences",".","Args",":","logits_lengths",":","tensor","with","lengths","of","logits","targets",":","tensor","with","target","units","target_lengths",":","tensor","with","lengths","of","targets","vocab_size",":","vocab","size","(","including","blank",")","Returns",":","batched","lattice","-","FsaVec","(","k2.Fsa",")"]
code: def get_graphs_batched(
      self,
      logits_lengths: torch.Tensor,
      targets: torch.Tensor,
      target_lengths: torch.Tensor,
      vocab_size: int,
  ) -> "k2.Fsa":
      """
      Get batched lattice (grid or composed) for the batch of sequences.
  
      Args:
          logits_lengths: tensor with lengths of logits
          targets: tensor with target units
          target_lengths: tensor with lengths of targets
          vocab_size: vocab size (including blank)
  
      Returns:
          batched lattice - FsaVec (k2.Fsa)
      """
      batch_size = logits_lengths.shape[0]
      with torch.no_grad():
          if self.use_grid_implementation:
              return k2.create_fsa_vec(
                  [
                      self.get_grid(
                          units_tensor=targets[
                              i, : target_lengths[i].item()
                          ],
                          num_frames=logits_lengths[i].item(),
                          vocab_size=vocab_size,
                      )
                      for i in range(batch_size)
                  ]
              )
  
          # composed version
          text_fsas = [
              self.get_unit_schema(
                  units_tensor=targets[i, : target_lengths[i].item()],
                  vocab_size=vocab_size,
              )
              for i in range(batch_size)
          ]
          temporal_fsas = [
              self.get_temporal_schema(
                  num_frames=logits_lengths[i].item(),
                  vocab_size=vocab_size,
                  device=targets.device,
              )
              for i in range(batch_size)
          ]
          target_fsas_vec = k2.compose(
              k2.create_fsa_vec(text_fsas),
              k2.create_fsa_vec(temporal_fsas),
              treat_epsilons_specially=False,
          )
          if self.connect_composed:
              k2.connect(target_fsas_vec)
      return target_fsas_vec
  
imports: import abc
  from contextlib import nullcontext
  from typing import ContextManager
  import torch
  import torch.nn.functional
  from nemo.core.classes.loss import Loss
  from nemo.core.utils.k2_guard import k2
label_desc: Use image node_id 6 for calling the GraphTransducerLossBase obj's underlying member method code with example usage: obj.get_graphs_batched(logits_lengths, targets, target_lengths, vocab_size) and returns: target_fsas_vec, k2