code: def evaluate(model, val_loader, batch_transforms, val_metric):
      # Reset val metric
      val_metric.reset()
      # Validation loop
      val_loss, batch_cnt = 0, 0
      val_iter = iter(val_loader)
      for images, targets in tqdm(val_iter):
          try:
              images = batch_transforms(images)
              out = model(
                  images, targets, return_preds=True, training=False
              )
              # Compute metric
              if len(out["preds"]):
                  words, _ = zip(*out["preds"])
              else:
                  words = []
              val_metric.update(targets, words)
  
              val_loss += out["loss"].numpy().mean()
              batch_cnt += 1
          except ValueError:
              print(
                  f"unexpected symbol/s in targets:\n{targets} \n--> skip batch"
              )
              continue
  
      val_loss /= batch_cnt
      result = val_metric.summary()
      return val_loss, result["raw"], result["unicase"]
  
file_path: doctr/references/recognition/evaluate_tensorflow.py
imports: import os
  import multiprocessing
  import time
  import tensorflow
  from tensorflow.keras import mixed_precision
  from tqdm import tqdm
  from doctr import datasets
  from doctr import transforms
  from doctr.datasets import VOCABS, DataLoader
  from doctr.models import recognition
  from doctr.utils.metrics import TextMatch
label_desc: Use image node_id 1 for calling a global function with example usage: evaluate(model, val_loader, batch_transforms, val_metric) and returns: val_loss,  result,  result