docstr: Add a new hypothesis to the list.
code: def add(self, hyp, sum_logprobs):
      """
      Add a new hypothesis to the list.
      """
      score = sum_logprobs / len(hyp) ** self.length_penalty
      if len(self) < self.num_beams or score > self.worst_score:
          self.beams.append((score, hyp))
          if len(self) > self.num_beams:
              sorted_scores = sorted(
                  [(s, idx) for idx, (s, _) in enumerate(self.beams)]
              )
              del self.beams[sorted_scores[0][1]]
              self.worst_score = sorted_scores[1][0]
          else:
              self.worst_score = min(score, self.worst_score)
  
imports: import inspect
  import warnings
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow.compiler.tf2xla.python.xla import dynamic_update_slice
  from .generation_tf_logits_process import TFForcedBOSTokenLogitsProcessor, TFForcedEOSTokenLogitsProcessor, TFForceTokensLogitsProcessor, TFLogitsProcessorList, TFMinLengthLogitsProcessor, TFNoBadWordsLogitsProcessor, TFNoRepeatNGramLogitsProcessor, TFRepetitionPenaltyLogitsProcessor, TFSuppressTokensAtBeginLogitsProcessor, TFSuppressTokensLogitsProcessor, TFTemperatureLogitsWarper, TFTopKLogitsWarper, TFTopPLogitsWarper
  from .models.auto import TF_MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING, TF_MODEL_FOR_VISION_2_SEQ_MAPPING
  from .tf_utils import shape_list, stable_softmax
  from .utils import ModelOutput, logging
label_desc: Use image node_id 3 for calling the BeamHypotheses obj's underlying member method code with example usage: obj.add(hyp, sum_logprobs) without return types