code: def save_to_json(
      output_filename,
      train_step_loss,
      train_epoch_loss,
      train_step_ppl,
      train_epoch_ppl,
      val_step_loss,
      val_epoch_loss,
      val_step_ppl,
      val_epoch_ppl,
  ):
      metrics_data = {
          "train_step_loss": train_step_loss,
          "train_epoch_loss": train_epoch_loss,
          "train_step_perplexity": train_step_ppl,
          "train_epoch_perplexity": train_epoch_ppl,
          "val_step_loss": val_step_loss,
          "val_epoch_loss": val_epoch_loss,
          "val_step_perplexity": val_step_ppl,
          "val_epoch_perplexity": val_epoch_ppl,
      }
      with open(output_filename, "w") as f:
          json.dump(metrics_data, f)
  
imports: import os
  import time
  import yaml
  from contextlib import nullcontext
  from pathlib import Path
  from pkg_resources import packaging
  from datetime import datetime
  import torch
  import torch.cuda.nccl
  import torch.distributed
  from torch.distributed.fsdp import StateDictType
  from torch.distributed.fsdp.sharded_grad_scaler import ShardedGradScaler
  from tqdm import tqdm
  from transformers import LlamaTokenizer
  import json
  from llama_recipes.model_checkpointing import save_model_checkpoint, save_model_and_optimizer_sharded, save_optimizer_checkpoint
  from llama_recipes.policies import fpSixteen, bfSixteen, get_llama_wrapper
  from llama_recipes.utils.memory_utils import MemoryTrace
  from accelerate.utils import is_xpu_available, is_ccl_available
label_desc: Use image node_id 15 for calling a global function with example usage: save_to_json(output_filename, train_step_loss, train_epoch_loss, train_step_ppl, train_epoch_ppl, val_step_loss, val_epoch_loss, val_step_ppl, val_epoch_ppl) without return types