code: def test_logged_metrics_has_logged_epoch_value(tmpdir, logger):
      class TestModel(BoringModel):
          def training_step(self, batch, batch_idx):
              self.log("epoch", -batch_idx, logger=True)
              return super().training_step(batch, batch_idx)
  
      model = TestModel()
      trainer_kwargs = {
          "default_root_dir": tmpdir,
          "limit_train_batches": 2,
          "limit_val_batches": 0,
          "max_epochs": 1,
          "logger": False,
      }
      if logger:
          trainer_kwargs["logger"] = CSVLogger(tmpdir)
      trainer = Trainer(**trainer_kwargs)
      if not logger:
          with pytest.warns(
              match=r"log\('epoch', ..., logger=True\)` but have no logger"
          ):
              trainer.fit(model)
      else:
          trainer.fit(model)
  
      # should not get overridden if logged manually
      assert trainer.logged_metrics == {"epoch": -1}
  
imports: import operator
  from functools import partial
  from unittest import mock
  from unittest.mock import Mock
  import pytest
  import torch
  from lightning.pytorch import LightningModule
  from lightning.pytorch.callbacks.callback import Callback
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.loggers import CSVLogger
  from lightning.pytorch.trainer import Trainer
  from lightning.pytorch.trainer.connectors.logger_connector.fx_validator import _FxValidator
  from lightning.pytorch.trainer.connectors.logger_connector.result import _ResultCollection
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_9_1
  from lightning.pytorch.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_11
  from lightning_utilities.core.imports import compare_version
  from torch.utils.data import DataLoader
  from torchmetrics import Accuracy, MeanAbsoluteError, MeanSquaredError, MetricCollection
  from torchmetrics import AveragePrecision
  from tests_pytorch.models.test_hooks import get_members
label_desc: Use image node_id 7 for calling a global function with example usage: test_logged_metrics_has_logged_epoch_value(tmpdir, logger) and returns: super