code: def validate_model(model: torch.nn.Module):
      validate_dataset = datasets.ImageFolder(
          root=image_path + "val", transform=data_transform
      )
      val_num = len(validate_dataset)
      validate_loader = torch.utils.data.DataLoader(
          validate_dataset,
          batch_size=batch_size,
          shuffle=False,
          num_workers=2,
      )
  
      model.eval()
      acc = 0.0  # accumulate accurate number / epoch
      with torch.no_grad():
          t1 = time.time()
          for val_data in tqdm(
              validate_loader, desc="validate model accuracy."
          ):
              val_images, val_labels = val_data
              outputs = model(
                  val_images.to(device)
              )  # eval model only have last output layer
              predict_y = torch.max(outputs, dim=1)[1]
              acc += torch.sum(
                  torch.eq(predict_y, val_labels.to(device))
              ).item()
          val_accurate = acc / val_num
          print(
              "test_accuracy: %.3f, time:%.3f"
              % (val_accurate, time.time() - t1)
          )
  
      return val_accurate
  
file_path: deep-learning-for-image-processing/deploying_service/pruning_model_pytorch/main.py
imports: import os
  import torch
  from torchvision import transforms, datasets
  import torch.nn.utils.prune
  import torch.nn.functional
  from tqdm import tqdm
  import time
  from model import resnet34
label_desc: Use image node_id 1 for calling a global function with example usage: validate_model(model) and returns: val_accurate