code: def test_parity_single_device(precision, accelerator):
      input_dtype = get_model_input_dtype(precision)
  
      cuda_reset()
  
      # Train with Fabric
      fabric = Fabric(
          precision=precision, accelerator=accelerator, devices=1
      )
      state_dict_fabric, timings_fabric, memory_fabric = train_fabric(
          fabric
      )
  
      cuda_reset()
  
      # Train with raw PyTorch
      state_dict_torch, timings_torch, memory_torch = train_torch(
          fabric.to_device,
          precision_context=fabric.autocast,
          input_dtype=input_dtype,
      )
  
      # Compare the final weights
      assert is_state_dict_equal(state_dict_torch, state_dict_fabric)
  
      # Compare the time per iteration
      assert is_timing_close(
          timings_torch, timings_fabric, rtol=1e-2, atol=0.1
      )
  
      # Compare memory usage
      if accelerator == "cuda":
          assert is_cuda_memory_close(
              memory_torch["start"], memory_fabric["start"]
          )
          assert is_cuda_memory_close(
              memory_torch["end"], memory_fabric["end"]
          )
  
file_path: pytorch-lightning/tests/parity_fabric/test_parity_simple.py
imports: import time
  from copy import deepcopy
  from typing import Callable
  import pytest
  import torch
  import torch.distributed
  import torch.nn.functional
  from lightning.fabric.fabric import Fabric
  from tests_fabric.helpers.runif import RunIf
  from parity_fabric.models import ConvNet
  from parity_fabric.utils import cuda_reset, get_model_input_dtype, is_cuda_memory_close, is_state_dict_equal, is_timing_close, make_deterministic
label_desc: Use image node_id 3 for calling a global function with example usage: test_parity_single_device(precision, accelerator) without return types