code: def add_results_to_json(js, nbest_hyps_sd, 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 (# Utts x # Spkrs).
          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"]
      num_spkrs = len(nbest_hyps_sd)
      new_js["output"] = []
  
      for ns in range(num_spkrs):
          tmp_js = []
          nbest_hyps = nbest_hyps_sd[ns]
  
          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
              out_dic = dict(js["output"][ns].items())
  
              # 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
              tmp_js.append(out_dic)
  
              # show 1-best result
              if n == 1:
                  logging.info("groundtruth: %s" % out_dic["text"])
                  logging.info("prediction : %s" % out_dic["rec_text"])
  
          new_js["output"].append(tmp_js)
      return new_js
  
file_path: espnet/espnet/asr/asr_mix_utils.py
imports: import copy
  import logging
  import os
  from chainer.training import extension
  from espnet.asr.asr_utils import parse_hypothesis
label_desc: Use image node_id 1 for calling a global function with example usage: add_results_to_json(js, nbest_hyps_sd, char_list) and returns: new_js