class_docstr: Wrapper class for sequence generators for NeMo transformers.
class_docstr_tok: ["Wrapper","class","for","sequence","generators","for","NeMo","transformers","."]
code: def __init__(
      self,
      cfg: DictConfig,
      embedding: NeuralModule,
      decoder: NeuralModule,
      log_softmax: NeuralModule,
      tokenizer: TokenizerSpec,
  ) -> None:
      super().__init__()
  
      self._type = cfg.get("type", "greedy")
      self.tokenizer = tokenizer
      self.pad_id = getattr(tokenizer, "pad_id", 0)
      self.eos_id = getattr(tokenizer, "eos_id", -1)
      self.bos_id = getattr(tokenizer, "bos_id", -1)
      common_args = {
          "pad": self.pad_id,
          "bos": self.bos_id,
          "eos": self.eos_id,
          "max_sequence_length": cfg.get("max_sequence_length", 512),
          "max_delta_length": cfg.get("max_delta_length", -1),
          "batch_size": cfg.get("batch_size", 1),
      }
      if self._type == self.TYPE_GREEDY:
          self.generator = GreedySequenceGenerator(
              embedding, decoder, log_softmax, **common_args
          )
      elif self._type == self.TYPE_TOPK:
          beam_size = cfg.get("beam_size", 1)
          temperature = cfg.get("temperature", 1.0)
          self.generator = TopKSequenceGenerator(
              embedding,
              decoder,
              log_softmax,
              beam_size,
              temperature,
              **common_args,
          )
      elif self._type == self.TYPE_BEAM:
          beam_size = cfg.get("beam_size", 1)
          len_pen = cfg.get("len_pen", 0.0)
          self.generator = BeamSearchSequenceGenerator(
              embedding,
              decoder,
              log_softmax,
              beam_size,
              len_pen,
              **common_args,
          )
      else:
          raise ValueError(
              f"Sequence Generator only supports one of {self.SEARCH_TYPES}, but got {self._type} instead."
          )
  
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 to create a new SequenceGenerator object  with example: obj = SequenceGenerator(cfg, embedding, decoder, log_softmax, tokenizer)