code: def test_rich_progress_bar_metrics_format(tmpdir, metrics_format):
      metric_name = "train_loss"
  
      class CustomModel(BoringModel):
          def training_step(self, *args, **kwargs):
              res = super().training_step(*args, **kwargs)
              self.log(metric_name, res["loss"], prog_bar=True)
              return res
  
      progress_bar = RichProgressBar(
          theme=RichProgressBarTheme(metrics_format=metrics_format)
      )
      trainer = Trainer(
          default_root_dir=tmpdir,
          fast_dev_run=True,
          callbacks=progress_bar,
      )
      model = CustomModel()
      trainer.fit(model)
  
      def extract_rendered_value():
          rendered = progress_bar.progress.columns[-1]._renderable_cache
          train_progress_bar_id = progress_bar.train_progress_bar_id
          rendered_text = str(rendered[train_progress_bar_id][1])
          return rendered_text.split(f"{metric_name}: ")[1]
  
      rendered_value = extract_rendered_value()
      value = trainer.logged_metrics[metric_name]
      formatted_value = f"{value:{metrics_format}}"
      assert rendered_value == formatted_value
  
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 21 for calling a global function with example usage: test_rich_progress_bar_metrics_format(tmpdir, metrics_format) and returns: rendered_text, res