class_docstr: Represents a sequence-to-sequence generator based on beam search.
class_docstr_tok: ["Represents","a","sequence-to-sequence","generator","based","on","beam","search","."]
code: def __call__(
      self,
      source_seqs: Tensor,
      source_padding_mask: Optional[PaddingMask],
      prompt_seqs: Tensor,
      prompt_padding_mask: Optional[PaddingMask],
  ) -> Seq2SeqGeneratorOutput:
      # (P, S)
      encoder_output, encoder_padding_mask = self.model.encode(
          source_seqs, source_padding_mask
      )
  
      if source_padding_mask is None:
          max_source_len = source_seqs.size(1)
      else:
          max_source_len = int(source_padding_mask.seq_lens.max())
  
      a_term, b_term = self.max_gen_len
  
      # In seq2seq generation, the maximum generation length is relative to
      # the source sequence length.
      max_gen_len = int(a_term * max_source_len + b_term)
  
      if max_gen_len < 1:
          raise ValueError(
              f"`max_gen_len` must be greater than or equal to 1, but is {max_gen_len} instead. Adjust your `max_gen_len` argument."
          )
  
      if self.min_gen_len > max_gen_len:
          raise ValueError(
              f"`min_gen_len` must be less than or equal to `max_gen_len` ({max_gen_len}), but is {self.min_gen_len} instead. Adjust your `max_gen_len` argument."
          )
  
      op = _BeamSearchSeq2SeqGeneratorOp(
          self.model,
          encoder_output,
          encoder_padding_mask,
          prompt_seqs,
          prompt_padding_mask,
          self.algorithm,
          self.beam_size,
          self.min_gen_len,
          max_gen_len,
          self.max_seq_len,
          self.echo_prompt,
          self.normalize_scores,
          self.temperature,
          self.unk_penalty,
          self.len_penalty,
          self.prefill_chunk_size,
          self.decode_capacity_increment,
          self.step_processors,
          self._step_hooks,
      )
  
      hypotheses = op()
  
      return Seq2SeqGeneratorOutput(
          hypotheses, encoder_output, encoder_padding_mask
      )
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from typing import Dict, List, Optional, Sequence, Tuple, Union, final
  import torch
  from torch import Tensor
  from torch.nn.functional import log_softmax
  from fairseq2.data import VocabularyInfo
  from fairseq2.generation.generator import Hypothesis, Seq2SeqGenerator, Seq2SeqGeneratorOutput, SequenceGenerator, SequenceGeneratorOutput, StepHook
  from fairseq2.generation.step_processor import StepProcessor
  from fairseq2.models.decoder import DecoderModel
  from fairseq2.models.encoder_decoder import EncoderDecoderModel
  from fairseq2.models.sequence import SequenceModelOutput
  from fairseq2.nn.incremental_state import IncrementalStateBag
  from fairseq2.nn.padding import PaddingMask
  from fairseq2.typing import finaloverride, override
label_desc: Use image node_id 2 for calling the BeamSearchSeq2SeqGenerator obj's underlying member method code with example usage: obj.__call__(source_seqs, source_padding_mask, prompt_seqs, prompt_padding_mask) and returns: Seq2SeqGeneratorOutput