code: def test_run(model_and_optimizers: TrainerParameters, device):
      if device != "cpu" and not torch.cuda.is_available():
          pytest.skip(f"No cuda for device:{device}")
      n_epochs = 2
      for progress_bar in ["rich", "auto", None, "raw", "tqdm"]:
          trainer = Trainer(
              model=model_and_optimizers.model,
              driver="torch",
              device=device,
              optimizers=model_and_optimizers.optimizers,
              train_dataloader=model_and_optimizers.train_dataloader,
              evaluate_dataloaders=model_and_optimizers.evaluate_dataloaders,
              input_mapping=model_and_optimizers.input_mapping,
              output_mapping=model_and_optimizers.output_mapping,
              metrics=model_and_optimizers.metrics,
              n_epochs=n_epochs,
              callbacks=None,
              progress_bar=progress_bar,
              output_from_new_proc="all",
              evaluate_fn="train_step",
              larger_better=False,
          )
  
          trainer.run()
  
          evaluator = Evaluator(
              model=model_and_optimizers.model,
              dataloaders=model_and_optimizers.train_dataloader,
              driver=trainer.driver,
              metrics=model_and_optimizers.metrics,
              progress_bar=progress_bar,
              evaluate_fn="train_step",
          )
          evaluator.run()
  
      if dist.is_initialized():
          dist.destroy_process_group()
  
file_path: fastNLP/tests/core/callbacks/test_progress_callback_torch.py
imports: from typing import Any
  from dataclasses import dataclass
  import pytest
  from fastNLP import Metric, Accuracy
  from tests.helpers.utils import magic_argv_env_context
  from fastNLP import Trainer, Evaluator
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from tests.helpers.models.torch_model import TorchNormalModel_Classification_1
  from tests.helpers.datasets.torch_data import TorchArgMaxDataset
label_desc: Use image node_id 2 for calling a global function with example usage: test_run(model_and_optimizers, device) without return types