code: def test_on_batch(
      model,
      inputs,
      targets,
      sample_weights=None,
      output_loss_metrics=None,
  ):
      """Calculates the loss for one input batch.
  
      Args:
          model: Model whose loss has to be calculated.
          inputs: Input batch data.
          targets: Target batch data.
          sample_weights: Sample weight batch data.
          output_loss_metrics: List of metrics that are used to aggregated output
            loss values.
  
      Returns:
          Dict with three items:
            'total_loss': single tensor for overall loss,
            'output_losses': list of tensors for loss corresponding to each of the
              model output. Could be a empty list when model has only one output.
            'metrics': list of tensors for metric specified.
      """
      inputs = training_utils_v1.cast_to_model_input_dtypes(
          inputs, model
      )
  
      with backend.eager_learning_phase_scope(0):
          outs, total_loss, output_losses, masks = _model_loss(
              model,
              inputs,
              targets,
              sample_weights=sample_weights,
              training=False,
              output_loss_metrics=output_loss_metrics,
          )
      if not isinstance(outs, list):
          outs = [outs]
      metrics_results = _eager_metrics_fn(
          model,
          outs,
          targets,
          sample_weights=sample_weights,
          masks=masks,
      )
      total_loss = nest.flatten(total_loss)
  
      return {
          "total_loss": total_loss,
          "output_losses": output_losses,
          "metrics": metrics_results,
      }
  
file_path: tensorflow-upstream/tensorflow/python/keras/engine/training_eager_v1.py
imports: import numpy
  from tensorflow.python.eager.backprop import GradientTape
  from tensorflow.python.framework import tensor_conversion
  from tensorflow.python.keras import backend
  from tensorflow.python.keras.engine import training_utils
  from tensorflow.python.keras.engine import training_utils_v1
  from tensorflow.python.keras.mixed_precision import loss_scale_optimizer
  from tensorflow.python.keras.utils import losses_utils
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import nest
label_desc: Use image node_id 6 for calling a global function with example usage: test_on_batch(model, inputs, targets, sample_weights, output_loss_metrics) and returns: dict