code: def select_response(
      ids,
      scores: List[float],
      tokenizer,
      max_dec_len: int = None,
      num_return_sequences: int = 1,
      keep_space: bool = True,
  ):
      """
      Select response with the highest score.
      """
      ids = ids.numpy().tolist()
      scores = scores.numpy()
  
      if (
          len(ids) != len(scores)
          or (len(ids) % num_return_sequences) != 0
      ):
          raise ValueError(
              "the length of `ids` is {}, but the `num_return_sequences` is {}".format(
                  len(ids), num_return_sequences
              )
          )
  
      group = []
      tmp = []
      for pred, score in zip(ids, scores):
          pred_token_ids, pred_tokens = post_process_response(
              pred, tokenizer
          )
          num_token = len(pred_token_ids)
          if keep_space:
              response = " ".join(pred_tokens)
          else:
              response = "".join(pred_tokens)
  
          in_turn_repetition = get_in_turn_repetition(
              pred_tokens, True
          ) or get_in_turn_repetition(pred_token_ids)
          # not ending
          if max_dec_len is not None and num_token >= max_dec_len:
              score -= 1e3
          elif in_turn_repetition:
              score -= 1e3
  
          tmp.append([response, score])
          if len(tmp) == num_return_sequences:
              group.append(tmp)
              tmp = []
  
      results = []
      for preds in group:
          preds = sorted(preds, key=lambda x: -x[1])
          results.append(preds[0][0])
      return results
  
imports: from typing import List
label_desc: Use image node_id 3 for calling a global function with example usage: select_response(ids, scores, tokenizer, max_dec_len, num_return_sequences, keep_space) and returns: results