code: def eval_model(model, valid_loader):
      model.eval()
      correct = 0
      with torch.no_grad():
          for batch_idx, (data, target) in enumerate(valid_loader):
              data, target = data.view(-1, 28 * 28).to(
                  DEVICE
              ), target.to(DEVICE)
              pred = model(data).argmax(dim=1, keepdim=True)
              correct += pred.eq(target.view_as(pred)).sum().item()
  
      accuracy = correct / N_VALID_EXAMPLES
  
      flops = FlopCountAnalysis(
          model, inputs=(torch.randn(1, 28 * 28).to(DEVICE),)
      ).total()
      return flops, accuracy
  
file_path: optuna/tutorial/20_recipes/002_multi_objective.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  import torchvision
  from fvcore.nn import FlopCountAnalysis
  import optuna
label_desc: Use image node_id 3 for calling a global function with example usage: eval_model(model, valid_loader) and returns: flops,  accuracy