code: def run_model_prediction(trained_model, dataloader, min_acc=0.50):
      orig_device = trained_model.device
      # run prediction on 1 batch
      trained_model.cpu()
      trained_model.eval()
  
      batch = next(iter(dataloader))
      x, y = batch
      x = x.flatten(1)
  
      y_hat = trained_model(x)
      metric = (
          partial(accuracy, task="multiclass")
          if _TM_GE_0_11
          else accuracy
      )
      acc = metric(
          y_hat.cpu(), y.cpu(), top_k=2, num_classes=y_hat.size(-1)
      ).item()
  
      assert (
          acc >= min_acc
      ), f"This model is expected to get > {min_acc} in test set (it got {acc})"
      trained_model.to(orig_device)
  
file_path: pytorch-lightning/tests/tests_pytorch/helpers/pipelines.py
imports: from functools import partial
  import torch
  from lightning.pytorch import LightningDataModule, LightningModule, Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_11
  from torchmetrics.functional import accuracy
  from tests_pytorch.helpers.utils import get_default_logger, load_model_from_checkpoint
label_desc: Use image node_id 3 for calling a global function with example usage: run_model_prediction(trained_model, dataloader, min_acc) without return types