code: def test_rich_progress_bar(tmp_path, dataset):
      class TestModel(BoringModel):
          def train_dataloader(self):
              return DataLoader(dataset=dataset)
  
          def val_dataloader(self):
              return DataLoader(dataset=dataset)
  
          def test_dataloader(self):
              return DataLoader(dataset=dataset)
  
          def predict_dataloader(self):
              return DataLoader(dataset=dataset)
  
      trainer = Trainer(
          default_root_dir=tmp_path,
          num_sanity_val_steps=0,
          limit_train_batches=1,
          limit_val_batches=1,
          limit_test_batches=1,
          limit_predict_batches=1,
          max_epochs=1,
          callbacks=RichProgressBar(),
      )
      model = TestModel()
  
      with mock.patch(
          "lightning.pytorch.callbacks.progress.rich_progress.Progress.update"
      ) as mocked:
          trainer.fit(model)
      # 2 for train progress bar and 1 for val progress bar
      assert mocked.call_count == 3
  
      with mock.patch(
          "lightning.pytorch.callbacks.progress.rich_progress.Progress.update"
      ) as mocked:
          trainer.validate(model)
      assert mocked.call_count == 1
  
      with mock.patch(
          "lightning.pytorch.callbacks.progress.rich_progress.Progress.update"
      ) as mocked:
          trainer.test(model)
      assert mocked.call_count == 1
  
      with mock.patch(
          "lightning.pytorch.callbacks.progress.rich_progress.Progress.update"
      ) as mocked:
          trainer.predict(model)
      assert mocked.call_count == 1
  
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 3 for calling a global function with example usage: test_rich_progress_bar(tmp_path, dataset) and returns: DataLoader, DataLoader, DataLoader, DataLoader