code: def test_throughput_monitor_eval(tmp_path, fn):
      logger_mock = Mock()
      logger_mock.save_dir = tmp_path
      monitor = ThroughputMonitor(
          batch_size_fn=lambda x: 3, window_size=3, separator="|"
      )
      model = BoringModel()
      model.flops_per_batch = 10
      trainer = Trainer(
          devices=1,
          logger=logger_mock,
          callbacks=monitor,
          limit_val_batches=6,
          limit_test_batches=6,
          limit_predict_batches=6,
          log_every_n_steps=3,
          enable_checkpointing=False,
          enable_model_summary=False,
          enable_progress_bar=False,
      )
      trainer_fn = getattr(trainer, fn)
  
      with mock.patch(
          "lightning.pytorch.callbacks.throughput_monitor.get_available_flops",
          return_value=100,
      ):
          trainer_fn(model)
          trainer_fn(model)
  
      expected = {
          f"{fn}|time": ANY,
          f"{fn}|device|batches_per_sec": ANY,
          f"{fn}|device|samples_per_sec": ANY,
          f"{fn}|device|flops_per_sec": ANY,
          f"{fn}|device|mfu": ANY,
      }
      assert logger_mock.log_metrics.mock_calls == [
          call(
              metrics={
                  **expected,
                  f"{fn}|batches": 3,
                  f"{fn}|samples": 9,
              },
              step=3,
          ),
          call(
              metrics={
                  **expected,
                  f"{fn}|batches": 6,
                  f"{fn}|samples": 18,
              },
              step=6,
          ),
          # the step doesnt repeat
          call(
              metrics={
                  **expected,
                  f"{fn}|batches": 9,
                  f"{fn}|samples": 27,
              },
              step=9,
          ),
          call(
              metrics={
                  **expected,
                  f"{fn}|batches": 12,
                  f"{fn}|samples": 36,
              },
              step=12,
          ),
      ]
  
file_path: pytorch-lightning/tests/tests_pytorch/callbacks/test_throughput_monitor.py
imports: from unittest import mock
  from unittest.mock import ANY, Mock, call
  import pytest
  import torch
  from lightning.fabric.utilities.throughput import measure_flops
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks.throughput_monitor import ThroughputMonitor
  from lightning.pytorch.demos.boring_classes import BoringModel
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 6 for calling a global function with example usage: test_throughput_monitor_eval(tmp_path, fn) without return types