code: def get_valid_stats(args, trainer, stats):
      stats["num_updates"] = trainer.get_num_updates()
      if hasattr(checkpoint_utils.save_checkpoint, "best"):
          key = "best_{0}".format(args.best_checkpoint_metric)
          best_function = (
              max if args.maximize_best_checkpoint_metric else min
          )
          stats[key] = best_function(
              checkpoint_utils.save_checkpoint.best,
              stats[args.best_checkpoint_metric],
          )
      return stats
  
imports: import argparse
  import logging
  import math
  import os
  import random
  import sys
  import numpy
  import torch
  from fairseq import checkpoint_utils, distributed_utils, options, quantization_utils, tasks, utils
  from fairseq.data import iterators
  from fairseq.logging import meters, metrics, progress_bar
  from fairseq.model_parallel.megatron_trainer import MegatronTrainer
  from .ls_fs_gcq_trainer import LSTrainer
label_desc: Use image node_id 7 for calling a global function with example usage: get_valid_stats(args, trainer, stats) and returns: stats