code: def main(args):
      print(args)
  
      if not isinstance(args.workers, int):
          args.workers = min(16, mp.cpu_count())
  
      # AMP
      if args.amp:
          mixed_precision.set_global_policy("mixed_float16")
  
      # Load doctr model
      model = recognition.__dict__[args.arch](
          pretrained=True if args.resume is None else False,
          input_shape=(args.input_size, 4 * args.input_size, 3),
          vocab=VOCABS[args.vocab],
      )
  
      # Resume weights
      if isinstance(args.resume, str):
          model.load_weights(args.resume)
  
      st = time.time()
      ds = datasets.__dict__[args.dataset](
          train=True,
          download=True,
          recognition_task=True,
          use_polygons=args.regular,
          img_transforms=T.Resize(
              (args.input_size, 4 * args.input_size),
              preserve_aspect_ratio=True,
          ),
      )
  
      _ds = datasets.__dict__[args.dataset](
          train=False,
          download=True,
          recognition_task=True,
          use_polygons=args.regular,
          img_transforms=T.Resize(
              (args.input_size, 4 * args.input_size),
              preserve_aspect_ratio=True,
          ),
      )
      ds.data.extend((np_img, target) for np_img, target in _ds.data)
  
      test_loader = DataLoader(
          ds,
          batch_size=args.batch_size,
          drop_last=False,
          num_workers=args.workers,
          shuffle=False,
      )
      print(
          f"Test set loaded in {time.time() - st:.4}s ({len(ds)} samples in "
          f"{len(test_loader)} batches)"
      )
  
      mean, std = model.cfg["mean"], model.cfg["std"]
      batch_transforms = T.Normalize(mean=mean, std=std)
  
      # Metrics
      val_metric = TextMatch()
  
      print("Running evaluation")
      val_loss, exact_match, partial_match = evaluate(
          model, test_loader, batch_transforms, val_metric
      )
      print(
          f"Validation loss: {val_loss:.6} (Exact: {exact_match:.2%} | Partial: {partial_match:.2%})"
      )
  
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 2 for calling a global function with example usage: main(args) without return types