code: def test_train_step_no_return(tmpdir):
      """Tests that only training_step raises a warning when nothing is returned in case of automatic_optimization."""
  
      class TestModel(BoringModel):
          def training_step(self, batch):
              self.training_step_called = True
              loss = self.step(batch[0])
              self.log("a", loss, on_step=True, on_epoch=True)
  
          def validation_step(self, batch, batch_idx):
              self.validation_step_called = True
  
      model = TestModel()
      trainer_args = {"default_root_dir": tmpdir, "fast_dev_run": 2}
      trainer = Trainer(**trainer_args)
  
      Closure.warning_cache.clear()
  
      with pytest.warns(
          UserWarning, match=r"training_step` returned `None"
      ):
          trainer.fit(model)
  
      assert model.training_step_called
      assert model.validation_step_called
  
      model = TestModel()
      model.automatic_optimization = False
      trainer = Trainer(**trainer_args)
  
      Closure.warning_cache.clear()
  
      with no_warning_call(
          UserWarning, match=r"training_step` returned `None"
      ):
          trainer.fit(model)
  
file_path: pytorch-lightning/tests/tests_pytorch/loops/test_training_loop_flow_scalar.py
imports: import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.core.module import LightningModule
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.loops.optimization.automatic import Closure
  from lightning.pytorch.trainer.states import RunningStage
  from lightning_utilities.test.warning import no_warning_call
  from torch import Tensor
  from torch.utils.data import DataLoader
  from torch.utils.data._utils.collate import default_collate
  from tests_pytorch.helpers.deterministic_model import DeterministicModel
label_desc: Use image node_id 4 for calling a global function with example usage: test_train_step_no_return(tmpdir) without return types