code: def write(
      self,
      time: float,
      iteration: int,
      loss: float,
      lr: float,
      lr_scale: float,
      time_usage: Dict[str, float],
      mem_usage: Dict[str, Tuple[float, float]],
      avg_time: float,
      token_max: float,
      token_pass: float,
      throughout: float,
      grad_norm: float,
      mask_max: float,
      num_gpus: int,
      task_loss: Dict[str, float],
      model_inspect: Optional[Any] = None,
  ):
      with open(self.get_log_name(), "a") as fp:
          ret = {
              "time": time,
              "iter": iteration,
              "loss": loss,
              "lr": lr,
              "lr scale": int(lr_scale),
              "time usage": time_usage,
              "mem usage": mem_usage,
              "avg time (s)": avg_time,
              "token/max": token_max,
              "token pass": token_pass + self.global_token_pass,
              "throughout (token/s)": throughout,
              "grad_norm": grad_norm,
              "mask/max": mask_max,
              "num_gpus": num_gpus,
              "task_loss": task_loss,
          }
          if model_inspect is not None:
              ret["model_inspect"] = model_inspect
          fp.write(json.dumps(ret, ensure_ascii=False) + "\n")
  
file_path: DeepKE/example/llm/CPM-Bee/src/cpm_live/utils/log.py
imports: import os
  import sys
  from typing import Any, Dict, Optional, Tuple, Union
  import datetime
  import json
  import logging
  import bmtrain
label_desc: Use image node_id 4 for calling the LogManager obj's underlying member method code with example usage: obj.write(time, iteration, loss, lr, lr_scale, time_usage, mem_usage, avg_time, token_max, token_pass, throughout, grad_norm, mask_max, num_gpus, task_loss, model_inspect) without return types