code: def vanilla_loop(
      cls_model, idx, device_type: str = "cuda", num_epochs=10
  ):
      device = torch.device(device_type)
      # set seed
      seed_everything(idx)
  
      # init model parts
      model = cls_model()
      dl = model.train_dataloader()
      optimizer = model.configure_optimizers()
  
      # model to GPU
      model = model.to(device)
  
      epoch_losses = []
      # as the first run is skipped, no need to run it long
      for epoch in range(num_epochs if idx > 0 else 1):
          # run through full training set
          for j, batch in enumerate(dl):
              batch = [x.to(device) for x in batch]
              loss_dict = model.training_step(batch, j)
              loss = loss_dict["loss"]
              loss.backward()
              optimizer.step()
              optimizer.zero_grad()
  
          # track last epoch loss
          epoch_losses.append(loss.item())
  
      return epoch_losses[-1], _hook_memory()
  
file_path: pytorch-lightning/tests/parity_pytorch/test_basic_parity.py
imports: import os
  import numpy
  import pytest
  import torch
  from lightning.pytorch import LightningModule, Trainer, seed_everything
  from tests_pytorch.helpers.advanced_models import ParityModuleMNIST, ParityModuleRNN
  from parity_pytorch.measure import measure_loops
  from parity_pytorch.models import ParityModuleCIFAR
label_desc: Use image node_id 5 for calling a global function with example usage: vanilla_loop(cls_model, idx, device_type, num_epochs) and returns: epoch_losses,  _hook_memory