class_docstr: Wrapper class for sequence generators for NeMo transformers.
class_docstr_tok: ["Wrapper","class","for","sequence","generators","for","NeMo","transformers","."]
docstr: Get sequence length.
  Params:
  -   seq: batched sequence tensor of shape BxTxD
  Returns:
  -   tensor of shape B, where each element is the length of the sequence
docstr_tok: ["Get","sequence","length",".","Params",":","-","seq",":","batched","sequence","tensor","of","shape","BxTxD","Returns",":","-","tensor","of","shape","B",",","where","each","element","is","the","length","of","the","sequence"]
code: def get_seq_length(self, seq: torch.Tensor) -> torch.Tensor:
      """
      Get sequence length.
      Params:
      -   seq: batched sequence tensor of shape BxTxD
      Returns:
      -   tensor of shape B, where each element is the length of the sequence
      """
      lengths = (
          seq.size(1)
          * torch.ones(seq.size(0), device=seq.device).long()
      )
      pos = (seq == self.eos_id).long().nonzero()
      seq_lengths = torch.scatter(
          lengths, dim=0, index=pos[:, 0], src=pos[:, 1]
      )
      return seq_lengths
  
file_path: NeMo/nemo/collections/asr/parts/utils/slu_utils.py
imports: from dataclasses import dataclass
  from typing import List, Optional
  import torch
  from omegaconf import DictConfig
  from nemo.collections.asr.modules.transformer import BeamSearchSequenceGenerator, GreedySequenceGenerator, TopKSequenceGenerator
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.core.classes.module import NeuralModule
label_desc: Use image node_id 3 for calling the SequenceGenerator obj's underlying member method code with example usage: obj.get_seq_length(seq) and returns: seq_lengths