code: def evaluate(model, val_loader, batch_transforms, amp=False):
      # Model in eval mode
      model.eval()
      # Validation loop
      val_loss, correct, samples, batch_cnt = 0, 0, 0, 0
      for images, targets in tqdm(val_loader):
          images = batch_transforms(images)
  
          if torch.cuda.is_available():
              images = images.cuda()
              targets = targets.cuda()
  
          if amp:
              with torch.cuda.amp.autocast():
                  out = model(images)
                  loss = cross_entropy(out, targets)
          else:
              out = model(images)
              loss = cross_entropy(out, targets)
          # Compute metric
          correct += (out.argmax(dim=1) == targets).sum().item()
  
          val_loss += loss.item()
          batch_cnt += 1
          samples += images.shape[0]
  
      val_loss /= batch_cnt
      acc = correct / samples
      return val_loss, acc
  
imports: import os
  import datetime
  import logging
  import multiprocessing
  import time
  import numpy
  import torch
  import wandb
  from torch.nn.functional import cross_entropy
  from torch.optim.lr_scheduler import CosineAnnealingLR, MultiplicativeLR, OneCycleLR
  from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
  from torchvision.transforms.v2 import Compose, GaussianBlur, InterpolationMode, Normalize, RandomGrayscale, RandomPerspective, RandomPhotometricDistort, RandomRotation
  from tqdm.auto import tqdm
  from doctr import transforms
  from doctr.datasets import VOCABS, CharacterGenerator
  from doctr.models import classification, login_to_hub, push_to_hf_hub
  from doctr.models.utils import export_model_to_onnx
  from utils import EarlyStopper, plot_recorder, plot_samples
label_desc: Use image node_id 3 for calling a global function with example usage: evaluate(model, val_loader, batch_transforms, amp) and returns: val_loss,  acc