code: def test_early_stopping_cpu_model(tmpdir):
      seed_everything(42)
  
      class ModelTrainVal(BoringModel):
          def validation_step(self, *args, **kwargs):
              output = super().validation_step(*args, **kwargs)
              self.log("val_loss", output["x"])
              return output
  
      stopping = EarlyStopping(monitor="val_loss", min_delta=0.1)
      trainer_options = {
          "callbacks": [stopping],
          "default_root_dir": tmpdir,
          "gradient_clip_val": 1.0,
          "enable_progress_bar": False,
          "accumulate_grad_batches": 2,
          "limit_train_batches": 0.3,
          "limit_val_batches": 0.1,
      }
  
      model = ModelTrainVal()
      tpipes.run_model_test(trainer_options, model)
  
      # test freeze on cpu
      model.freeze()
      model.unfreeze()
  
file_path: pytorch-lightning/tests/tests_pytorch/models/test_cpu.py
imports: import os
  from unittest import mock
  import torch
  from lightning.pytorch import Trainer, seed_everything
  from lightning.pytorch.callbacks import Callback, EarlyStopping, ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel
  import tests_pytorch.helpers.pipelines
  import tests_pytorch.helpers.utils
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
label_desc: Use image node_id 2 for calling a global function with example usage: test_early_stopping_cpu_model(tmpdir) and returns: output