code: def test_rich_progress_bar_correct_value_epoch_end(tmp_path):
      """Rich counterpart to test_tqdm_progress_bar::test_tqdm_progress_bar_correct_value_epoch_end."""
  
      class MockedProgressBar(RichProgressBar):
          calls = defaultdict(list)
  
          def get_metrics(self, trainer, pl_module):
              items = super().get_metrics(trainer, model)
              del items["v_num"]
              # this is equivalent to mocking `set_postfix` as this method gets called every time
              self.calls[trainer.state.fn].append(
                  (
                      trainer.state.stage,
                      trainer.current_epoch,
                      trainer.global_step,
                      items,
                  )
              )
              return items
  
      class MyModel(BoringModel):
          def training_step(self, batch, batch_idx):
              self.log(
                  "a",
                  self.global_step,
                  prog_bar=True,
                  on_step=False,
                  on_epoch=True,
                  reduce_fx=max,
              )
              return super().training_step(batch, batch_idx)
  
          def validation_step(self, batch, batch_idx):
              self.log(
                  "b",
                  self.global_step,
                  prog_bar=True,
                  on_step=False,
                  on_epoch=True,
                  reduce_fx=max,
              )
              return super().validation_step(batch, batch_idx)
  
          def test_step(self, batch, batch_idx):
              self.log(
                  "c",
                  self.global_step,
                  prog_bar=True,
                  on_step=False,
                  on_epoch=True,
                  reduce_fx=max,
              )
              return super().test_step(batch, batch_idx)
  
      model = MyModel()
      pbar = MockedProgressBar()
      trainer = Trainer(
          default_root_dir=tmp_path,
          limit_train_batches=2,
          limit_val_batches=2,
          limit_test_batches=2,
          max_epochs=2,
          enable_model_summary=False,
          enable_checkpointing=False,
          log_every_n_steps=1,
          callbacks=pbar,
          logger=CSVLogger(tmp_path),
      )
  
      trainer.fit(model)
      assert pbar.calls["fit"] == [
          ("sanity_check", 0, 0, {"b": 0}),
          ("train", 0, 1, {}),
          ("train", 0, 2, {}),
          ("validate", 0, 2, {"b": 2}),  # validation end
          # epoch end over, `on_epoch=True` metrics are computed
          ("train", 0, 2, {"a": 1, "b": 2}),  # training epoch end
          ("train", 1, 3, {"a": 1, "b": 2}),
          ("train", 1, 4, {"a": 1, "b": 2}),
          ("validate", 1, 4, {"a": 1, "b": 4}),  # validation end
          ("train", 1, 4, {"a": 3, "b": 4}),  # training epoch end
      ]
  
      trainer.validate(model, verbose=False)
      assert pbar.calls["validate"] == []
  
      trainer.test(model, verbose=False)
      assert pbar.calls["test"] == []
  
imports: import pickle
  from collections import defaultdict
  from unittest import mock
  from unittest.mock import DEFAULT, Mock
  import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import ProgressBar, RichProgressBar
  from lightning.pytorch.callbacks.progress.rich_progress import RichProgressBarTheme
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset, RandomIterableDataset
  from lightning.pytorch.loggers import CSVLogger
  from lightning.pytorch.loggers.logger import DummyLogger
  from tests_pytorch.helpers.runif import RunIf
  from torch.utils.data import DataLoader
label_desc: Use image node_id 16 for calling a global function with example usage: test_rich_progress_bar_correct_value_epoch_end(tmp_path) and returns: items, super, super, super