code: def __init__(
      self,
      beam_size: int,
      eot: int,
      inference: Inference,
      patience: Optional[float] = None,
  ):
      self.beam_size = beam_size
      self.eot = eot
      self.inference = inference
      self.patience = patience or 1.0
      self.max_candidates: int = round(beam_size * self.patience)
      self.finished_sequences = None
  
      assert (
          self.max_candidates > 0
      ), f"Invalid beam size ({beam_size}) or patience ({patience})"
  
imports: from dataclasses import dataclass, field, replace
  from typing import TYPE_CHECKING, Dict, Iterable, List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
  from torch import Tensor
  from torch.distributions import Categorical
  from .audio import CHUNK_LENGTH
  from .tokenizer import Tokenizer, get_tokenizer
  from .utils import compression_ratio
label_desc: Use image node_id 1 to create a new BeamSearchDecoder object from inherited base classes: TokenDecoder with example: obj = BeamSearchDecoder(beam_size, eot, inference, patience)