code: def total_metrics(model, dataset, batch_size):
      """This function calculates loss and accuracy metrics for the entire supplied
      dataset. The computation is performed one batch at a time; the returned
      numbers are normalized by the full dataset's count.
  
      Returns a dict with "loss" and "accuracy" keys.
  
      """
      total_loss = 0
      total_acc = 0.0
      total_samples = 0
  
      for batch in dataset.batch(batch_size):
          n = len(batch)
          images = batch["image"]
          labels = batch["label"]
          batch_loss, batch_acc = compute_batch_loss_acc(
              model, images, labels, training=True
          )
          # NON-normalized quantities. Sum of all loss.
          total_loss += batch_loss * n
          total_acc += batch_acc * n
          total_samples += n
  
      # so this is the running total loss so far.
      total_loss /= total_samples
      total_acc /= total_samples
  
      # RUNNING average of total loss and accuracy.
      return {"loss": total_loss, "accuracy": total_acc}
  
imports: from __future__ import division, print_function
  import getpass
  from typing import Dict, Optional
  import fs
  import tensorflow
  import tensorflow_datasets
  import tqdm
  import uv
  import uv.tensorflow.reporter
  import uv.util
  from absl import app
  from uv.fs.reporter import FSReporter
  from uv.mlflow.reporter import MLFlowReporter
  from trainer import cli
label_desc: Use image node_id 7 for calling a global function with example usage: total_metrics(model, dataset, batch_size) and returns: dict