code: def test(model, data_loader, device=None):
      device = device or torch.device("cpu")
      model.eval()
      correct = 0
      total = 0
      with torch.no_grad():
          for batch_idx, (data, target) in enumerate(data_loader):
              if batch_idx * len(data) > TEST_SIZE:
                  break
              data, target = data.to(device), target.to(device)
              outputs = model(data)
              _, predicted = torch.max(outputs.data, 1)
              total += target.size(0)
              correct += (predicted == target).sum().item()
  
      return correct / total
  
file_path: ray/doc/source/tune/doc_code/pytorch_optuna.py
imports: import os
  from filelock import FileLock
  import torch.nn
  import torch.nn.functional
  from torchvision import datasets, transforms
  import torch
  from ray import train, tune
  from ray.tune.search.optuna import OptunaSearch
label_desc: Use image node_id 2 for calling a global function with example usage: test(model, data_loader, device) and returns: unknown