docstr: Check whether decoding for a sentence is finished, which
  occurs when the list of finalized sentences has reached the
  beam size, or when we reach the maximum length.
docstr_tok: ["Check","whether","decoding","for","a","sentence","is","finished",",","which","occurs","when","the","list","of","finalized","sentences","has","reached","the","beam","size",",","or","when","we","reach","the","maximum","length","."]
code: def is_finished(
      self,
      step: int,
      unfin_idx: int,
      max_len: int,
      finalized_sent_len: int,
      beam_size: int,
  ):
      """
      Check whether decoding for a sentence is finished, which
      occurs when the list of finalized sentences has reached the
      beam size, or when we reach the maximum length.
      """
      assert finalized_sent_len <= beam_size
      if finalized_sent_len == beam_size or step == max_len:
          return True
      return False
  
imports: import math
  from typing import Dict, List, Optional
  from omegaconf.listconfig import ListConfig
  from omegaconf.dictconfig import DictConfig
  import torch
  import torch.nn
  from fairseq.models import FairseqIncrementalDecoder
  from torch import Tensor
  from fairseq.ngram_repeat_block import NGramRepeatBlock
  from .multichannel_search import ContiguousMultichannelBeamSearch
  from fairseq.models.speech_dlm import SpeechDLM
label_desc: Use image node_id 9 for calling the MultichannelSequenceGenerator obj's underlying member method code with example usage: obj.is_finished(step, unfin_idx, max_len, finalized_sent_len, beam_size) and returns: False, True