code: def test(model, device, test_loader, use_fp8):
      """Testing function."""
      model.eval()
      test_loss = 0
      correct = 0
      with torch.no_grad():
          for data, target in test_loader:
              data, target = data.to(device), target.to(device)
              with te.fp8_autocast(enabled=use_fp8):
                  output = model(data)
              test_loss += F.nll_loss(
                  output, target, reduction="sum"
              ).item()  # sum up batch loss
              pred = output.argmax(
                  dim=1, keepdim=True
              )  # get the index of the max log-probability
              correct += pred.eq(target.view_as(pred)).sum().item()
  
      test_loss /= len(test_loader.dataset)
  
      print(
          f"\nTest set: Average loss: {test_loss:.4f}, "
          f"Accuracy: {correct}/{len(test_loader.dataset)} "
          f"({100. * correct / len(test_loader.dataset):.0f}%)\n"
      )
  
file_path: colossalai/examples/community/fp8/mnist/main.py
imports: import argparse
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torch.optim.lr_scheduler import StepLR
  from torchvision import datasets, transforms
label_desc: Use image node_id 3 for calling a global function with example usage: test(model, device, test_loader, use_fp8) without return types