code: def extend_alignment(
      self, alignment, src_lengths, prev_output_tokens
  ):
      # alignment:    B X N
      # src_lengths:  B X T
      # prev_output_tokens:    B X (N + 1)
      tgt_tokens = prev_output_tokens[
          :, 1:
      ]  # remove the leading start of sentence token
      ext_alignment = (
          torch.ones(
              len(src_lengths),
              src_lengths.max(),
              device=src_lengths.device,
          )
          .long()
          .fill_(self.dictionary.pad())
      )
      for bs in range(src_lengths.size(0)):
          tgt_length = (
              tgt_tokens[bs].ne(self.dictionary.pad()).sum().item()
          )
          assert tgt_length == sum(alignment[bs].ne(1)) + 1
          src_st = 0
          for i in range(tgt_length):
              tok = tgt_tokens[bs][i]
              src_ed = (alignment[bs][i] * src_lengths[bs]).int().item()
              ext_alignment[bs][src_st:src_ed].fill_(tok)
              src_st = src_ed
      return ext_alignment
  
imports: import logging
  from collections import OrderedDict, namedtuple
  from typing import Dict, Optional
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from fairseq import checkpoint_utils, utils
  from fairseq.file_io import PathManager
  from fairseq.models import FairseqDecoder, FairseqEncoderDecoderModel, register_model, register_model_architecture
  from fairseq.models.speech_to_text import MultiInputDecoder, MultiModalityEncoder, SpeechWavTransformerEncoder, StackedSpeechWavTransformerEncoder
  from fairseq.models.transformer import TransformerDecoder, TransformerEncoder, TransformerModel
label_desc: Use image node_id 2 for calling the SpeechDummyDecoder obj's underlying member method code with example usage: obj.extend_alignment(alignment, src_lengths, prev_output_tokens) and returns: ext_alignment