code: def lightning_loop(
      cls_model, idx, device_type: str = "cuda", num_epochs=10
  ):
      seed_everything(idx)
  
      model = cls_model()
      # init model parts
      trainer = Trainer(
          # as the first run is skipped, no need to run it long
          max_epochs=num_epochs if idx > 0 else 1,
          enable_progress_bar=False,
          enable_model_summary=False,
          enable_checkpointing=False,
          accelerator="gpu" if device_type == "cuda" else "cpu",
          devices=1,
          logger=False,
          use_distributed_sampler=False,
          benchmark=False,
      )
      trainer.fit(model)
  
      return model._loss[-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 6 for calling a global function with example usage: lightning_loop(cls_model, idx, device_type, num_epochs) and returns: model,  _hook_memory