class_docstr: Megatron GPT Supervised Fine-Tuning
class_docstr_tok: ["Megatron","GPT","Supervised","Fine-Tuning"]
code: def write_predictions_to_file(self, outputs, output_file_path_prefix):
      output_file_path = (
          output_file_path_prefix + "_inputs_preds_labels.jsonl"
      )
      with open(output_file_path, "w") as f_json:
          assert (
              len(outputs["inputs"])
              == len(outputs["preds"])
              == len(outputs["labels"])
              == len(outputs["metadata"])
          )
          for i, p, l, m in zip(
              outputs["inputs"],
              outputs["preds"],
              outputs["labels"],
              outputs["metadata"],
          ):
              json_string = {"input": i, "pred": p, "label": l}
              for k, v in m.items():
                  if k not in json_string:
                      json_string[k] = v
              f_json.write(json.dumps(json_string) + "\n")
  
      logging.info(f"Predictions saved to {output_file_path}")
  
imports: import itertools
  import json
  from functools import partial
  from typing import Any, Optional
  import torch
  from omegaconf import DictConfig, ListConfig
  from pytorch_lightning.trainer.trainer import Trainer
  from nemo.collections.common.metrics import MetricStringToTorchMetric
  from nemo.collections.nlp.data.language_modeling.megatron.base_dataset_utils import get_datasets_weights_and_num_samples
  from nemo.collections.nlp.data.language_modeling.megatron.blendable_dataset import BlendableDataset
  from nemo.collections.nlp.data.language_modeling.megatron.gpt_sft_chat_dataset import GPTSFTChatDataset
  from nemo.collections.nlp.data.language_modeling.megatron.gpt_sft_dataset import GPTSFTDataset, GPTSFTPackedDataset
  from nemo.collections.nlp.data.language_modeling.megatron.megatron_batch_samplers import MegatronPretrainingBatchSampler
  from nemo.collections.nlp.models.language_modeling.megatron_gpt_model import MegatronGPTModel
  from nemo.collections.nlp.modules.common.megatron.utils import get_iterator_k_split
  from nemo.collections.nlp.modules.common.text_generation_utils import generate, get_computeprob_response
  from nemo.collections.nlp.parts.mixins.nlp_adapter_mixins import NLPAdapterModelMixin
  from nemo.collections.nlp.parts.utils_funcs import get_last_rank
  from nemo.utils import AppState, logging
label_desc: Use image node_id 13 for calling the MegatronGPTSFTModel obj's underlying member method code with example usage: obj.write_predictions_to_file(outputs, output_file_path_prefix) without return types