code: def test_trainer_output_from_new_proc(
      model_and_optimizers: TrainerParameters,
      driver,
      device,
      output_from_new_proc,
      n_epochs=2,
  ):
      std_msg = "std_msg"
      err_msg = "err_msg"
  
      from fastNLP.core.log.logger import logger
  
      with Capturing() as output:
          trainer = Trainer(
              model=model_and_optimizers.model,
              driver=driver,
              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,
              output_from_new_proc=output_from_new_proc,
          )
  
          if trainer.driver.get_local_rank() != 0:
              logger.warning(std_msg)
              sys.stderr.write(err_msg)
  
          trainer.run()
  
          if dist.is_initialized():
              dist.destroy_process_group()
  
      if output_from_new_proc == "all":
          if trainer.driver.get_local_rank() != 0:
              assert std_msg in output[0]
              assert err_msg in output[0]
      elif output_from_new_proc == "ignore":
          if trainer.driver.get_local_rank() != 0:
              assert std_msg not in output[0]
              assert err_msg not in output[0]
      elif output_from_new_proc == "only_error":
          if trainer.driver.get_local_rank() != 0:
              assert std_msg not in output[0]
              assert err_msg in output[0]
      else:
          std_path = Path(
              os.path.abspath(output_from_new_proc)
          ).joinpath(f"{trainer.driver.get_local_rank()}_std.log")
          assert std_path.exists()
          err_path = Path(
              os.path.abspath(output_from_new_proc)
          ).joinpath(f"{trainer.driver.get_local_rank()}_err.log")
          assert err_path.exists()
  
          path = Path(os.path.abspath(output_from_new_proc))
          rank_zero_rm(path)
  
imports: import os.path
  import subprocess
  import sys
  import pytest
  from dataclasses import dataclass
  from typing import Any
  from pathlib import Path
  from fastNLP.core.controllers.trainer import Trainer
  from tests.helpers.models.torch_model import TorchNormalModel_Classification_1, TorchNormalModel_Classification_3
  from tests.helpers.datasets.torch_data import TorchNormalDataset_Classification
  from tests.helpers.callbacks.helper_callbacks import RecordLossCallback
  from tests.helpers.callbacks.helper_callbacks_torch import RecordAccumulationStepsCallback_Torch
  from tests.helpers.utils import magic_argv_env_context, Capturing
  from fastNLP.envs.distributed import rank_zero_rm
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH, _TORCH_GREATER_EQUAL_1_12
label_desc: Use image node_id 5 for calling a global function with example usage: test_trainer_output_from_new_proc(model_and_optimizers, driver, device, output_from_new_proc, n_epochs) without return types