code: def test_logging_multi_dataloader_on_epoch_end(
      mock_log_metrics, tmpdir
  ):
      class CustomBoringModel(BoringModel):
          outputs = [[], []]
  
          def test_step(self, batch, batch_idx, dataloader_idx):
              value = dataloader_idx + 1
              self.log("foo", value)
              self.outputs[dataloader_idx].append(value)
              return value
  
          def on_test_epoch_end(self):
              self.log("foobar", sum(sum(o) for o in self.outputs))
  
          def test_dataloader(self):
              return [
                  super().test_dataloader(),
                  super().test_dataloader(),
              ]
  
      model = CustomBoringModel()
      trainer = Trainer(
          default_root_dir=tmpdir,
          limit_test_batches=1,
          logger=TensorBoardLogger(tmpdir),
      )
      results = trainer.test(model)
  
      # what's logged in `on_test_epoch_end` gets included in the results of each dataloader
      assert results == [
          {"foo/dataloader_idx_0": 1, "foobar": 3},
          {"foo/dataloader_idx_1": 2, "foobar": 3},
      ]
      cb_metrics = set(trainer.callback_metrics)
      assert cb_metrics == {
          "foo/dataloader_idx_0",
          "foo/dataloader_idx_1",
          "foobar",
      }
  
      mock_call = mock_log_metrics.mock_calls[0]
      logged_metrics = (
          mock_call.kwargs["metrics"]
          if _PYTHON_GREATER_EQUAL_3_8_0
          else mock_call[2]["metrics"]
      )
      cb_metrics.add("epoch")
      assert set(logged_metrics) == cb_metrics
  
imports: import collections
  import itertools
  import os
  from contextlib import redirect_stdout
  from io import StringIO
  from unittest import mock
  from unittest.mock import ANY, call
  import numpy
  import pytest
  import torch
  from lightning.fabric.utilities.imports import _PYTHON_GREATER_EQUAL_3_8_0
  from lightning.pytorch import Trainer, callbacks
  from lightning.pytorch.callbacks.progress.rich_progress import _RICH_AVAILABLE
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.loggers import TensorBoardLogger
  from lightning.pytorch.loops import _EvaluationLoop
  from lightning.pytorch.trainer.states import RunningStage
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch import Tensor
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 14 for calling a global function with example usage: test_logging_multi_dataloader_on_epoch_end(mock_log_metrics, tmpdir) and returns: value, list