code: def get_seq_length(seq: torch.Tensor, eos_id: int) -> torch.Tensor:
      """
      Get sequence length.
      Params:
      -   seq: batched sequence tensor of shape BxTxD
      -   eos_id: integer representing the end of sentence
      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 == 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 1 for calling a global function with example usage: get_seq_length(seq, eos_id) and returns: seq_lengths