code: def write_predictions_to_file(
      predictions: List[dict],
      input_json_files: List[str],
      output_dir: str,
      schemas: object,
      state_tracker: str,
      eval_debug: bool,
      in_domain_services: set,
  ):
      """Save predicted dialogues as json files.
  
      Args:
          predictions: An iterator containing model predictions. This is the output of
              the predict method in the estimator.
          input_json_files: A list of json paths containing the dialogues to run
              inference on.
          output_dir: The directory where output json files will be created.
          schemas: Schemas to all services in the dst dataset
          state_tracker: state tracker option
          eval_debug: output evaluation debugging information
          in_domain_services: in domain services
      """
      logging.info(f"Writing predictions to {output_dir} started.")
  
      # Index all predictions.
      all_predictions = defaultdict(
          lambda: defaultdict(lambda: defaultdict(dict))
      )
      for idx, prediction in enumerate(predictions):
          (
              eval_dataset,
              dialog_id,
              turn_id,
              service_name,
              model_task,
              slot_intent_id,
              value_id,
          ) = prediction["example_id"].split("-")
          all_predictions[(dialog_id, turn_id, service_name)][
              int(model_task)
          ][int(slot_intent_id)][int(value_id)] = prediction
      logging.info(
          f"Predictions for {idx} examples in {eval_dataset} dataset are getting processed."
      )
  
      # Read each input file and write its predictions.
      for input_file_path in input_json_files:
          with open(input_file_path, encoding="UTF-8") as f:
              dialogs = json.load(f)
              logging.debug(f"{input_file_path} file is loaded")
              pred_dialogs = []
              for d in dialogs:
                  pred_dialog = get_predicted_dialog(
                      d, all_predictions, schemas, state_tracker
                  )
                  pred_dialogs.append(pred_dialog)
          input_file_name = os.path.basename(input_file_path)
          output_file_path = os.path.join(output_dir, input_file_name)
          with open(output_file_path, "w", encoding="UTF-8") as f:
              json.dump(
                  pred_dialogs,
                  f,
                  indent=2,
                  separators=(",", ": "),
                  sort_keys=True,
              )
  
file_path: NeMo/nemo/collections/nlp/data/dialogue/sgd/prediction_utils.py
imports: import json
  import os
  from collections import OrderedDict, defaultdict
  from typing import Dict, List, Optional
  from nemo.collections.nlp.data.dialogue.input_example.sgd_input_example import STATUS_ACTIVE, STATUS_DONTCARE, STR_DONTCARE
  from nemo.utils import logging
label_desc: Use image node_id 6 for calling a global function with example usage: write_predictions_to_file(predictions, input_json_files, output_dir, schemas, state_tracker, eval_debug, in_domain_services) without return types