code: def add_results_to_json(js, nbest_hyps, char_list):
      """Add N-best results to json.
  
      Args:
          js (dict[str, Any]): Groundtruth utterance dict.
          nbest_hyps_sd (list[dict[str, Any]]):
              List of hypothesis for multi_speakers: nutts x nspkrs.
          char_list (list[str]): List of characters.
  
      Returns:
          dict[str, Any]: N-best results added utterance dict.
  
      """
      # copy old json info
      new_js = dict()
      new_js["utt2spk"] = js["utt2spk"]
      new_js["output"] = []
  
      for n, hyp in enumerate(nbest_hyps, 1):
          # parse hypothesis
          rec_text, rec_token, rec_tokenid, score = parse_hypothesis(
              hyp, char_list
          )
  
          # copy ground-truth
          if len(js["output"]) > 0:
              out_dic = dict(js["output"][0].items())
          else:
              # for no reference case (e.g., speech translation)
              out_dic = {"name": ""}
  
          # update name
          out_dic["name"] += "[%d]" % n
  
          # add recognition results
          out_dic["rec_text"] = rec_text
          out_dic["rec_token"] = rec_token
          out_dic["rec_tokenid"] = rec_tokenid
          out_dic["score"] = score
  
          # add to list of N-best result dicts
          new_js["output"].append(out_dic)
  
          # show 1-best result
          if n == 1:
              if "text" in out_dic.keys():
                  logging.info("groundtruth: %s" % out_dic["text"])
              logging.info("prediction : %s" % out_dic["rec_text"])
  
      return new_js
  
imports: import argparse
  import copy
  import json
  import logging
  import os
  import shutil
  import tempfile
  import numpy
  import torch
label_desc: Use image node_id 17 for calling a global function with example usage: add_results_to_json(js, nbest_hyps, char_list) and returns: new_js