code: def _process_metric_to_json(
      name, value, unit=None, global_step=None, extras=None
  ):
      """Validate the metric data and generate JSON for insert."""
      if not isinstance(value, numbers.Number):
          tf.compat.v1.logging.warning(
              "Metric value to log should be a number. Got %s",
              type(value),
          )
          return None
  
      extras = _convert_to_json_dict(extras)
      return {
          "name": name,
          "value": float(value),
          "unit": unit,
          "global_step": global_step,
          "timestamp": datetime.datetime.utcnow().strftime(
              _DATE_TIME_FORMAT_PATTERN
          ),
          "extras": extras,
      }
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import datetime
  import json
  import multiprocessing
  import numbers
  import os
  import threading
  import uuid
  from six.moves import _thread
  from absl import flags
  import tensorflow
  from tensorflow.python.client import device_lib
  from utils.logs import cloud_lib
label_desc: Use image node_id 5 for calling a global function with example usage: _process_metric_to_json(name, value, unit, global_step, extras) and returns: dict, None