code: def test_outputs_format(tmpdir):
      """Tests that outputs objects passed to model hooks and methods are consistent and in the correct format."""
  
      class HookedModel(BoringModel):
          def training_step(self, batch, batch_idx):
              output = super().training_step(batch, batch_idx)
              self.log("foo", 123)
              output["foo"] = 123
              return output
  
          @staticmethod
          def _check_output(output):
              assert "loss" in output
              assert "foo" in output
              assert output["foo"] == 123
  
          def on_train_batch_end(self, outputs, *_):
              HookedModel._check_output(outputs)
  
      model = HookedModel()
  
      # fit model
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=1,
          limit_val_batches=1,
          limit_train_batches=2,
          limit_test_batches=1,
          enable_progress_bar=False,
          enable_model_summary=False,
      )
      trainer.fit(model)
  
file_path: pytorch-lightning/tests/tests_pytorch/loops/test_training_loop.py
imports: import logging
  from unittest.mock import Mock
  import pytest
  import torch
  from lightning.pytorch import Trainer, seed_everything
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loops import _FitLoop
label_desc: Use image node_id 1 for calling a global function with example usage: test_outputs_format(tmpdir) and returns: output