docstr: Add a new hypothesis to the list.
docstr_tok: ["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.n_hyp or score > self.worst_score:
          self.hyp.append((score, hyp))
          if len(self) > self.n_hyp:
              sorted_scores = sorted(
                  [(s, idx) for idx, (s, _) in enumerate(self.hyp)]
              )
              del self.hyp[sorted_scores[0][1]]
              self.worst_score = sorted_scores[1][0]
          else:
              self.worst_score = min(score, self.worst_score)
  
file_path: DeepKE/example/llm/CPM-Bee/src/cpm_live/generation/generation_utils.py
imports: import torch
  import torch.nn.functional
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