code: def test_trainer_deepspeed(
      device,
      callbacks,
      strategy,
      config,
      n_epochs=2,
  ):
      model = TorchNormalModel_Classification_1(
          num_labels=TrainDeepSpeedConfig.num_labels,
          feature_dimension=TrainDeepSpeedConfig.feature_dimension,
      )
      optimizers = Adam(params=model.parameters(), lr=0.0001)
      train_dataloader = DataLoader(
          dataset=TorchArgMaxDataset(
              TrainDeepSpeedConfig.feature_dimension, 20
          ),
          batch_size=TrainDeepSpeedConfig.batch_size,
          shuffle=True,
      )
      val_dataloader = DataLoader(
          dataset=TorchArgMaxDataset(
              TrainDeepSpeedConfig.feature_dimension, 12
          ),
          batch_size=TrainDeepSpeedConfig.batch_size,
          shuffle=True,
      )
      train_dataloader = train_dataloader
      evaluate_dataloaders = val_dataloader
      evaluate_every = TrainDeepSpeedConfig.evaluate_every
      metrics = {"acc": Accuracy()}
      if config is not None:
          config[
              "train_micro_batch_size_per_gpu"
          ] = TrainDeepSpeedConfig.batch_size
      trainer = Trainer(
          model=model,
          driver="deepspeed",
          device=device,
          optimizers=optimizers,
          train_dataloader=train_dataloader,
          evaluate_dataloaders=evaluate_dataloaders,
          evaluate_every=evaluate_every,
          metrics=metrics,
          output_mapping={"preds": "pred"},
          n_epochs=n_epochs,
          callbacks=callbacks,
          deepspeed_kwargs={"strategy": strategy, "config": config},
      )
      trainer.run()
  
file_path: fastNLP/tests/core/controllers/_test_trainer_deepspeed.py
imports: import sys
  from dataclasses import dataclass
  from fastNLP.core.controllers.trainer import Trainer
  from fastNLP.core.metrics.accuracy import Accuracy
  from fastNLP.core.callbacks.progress_callback import RichCallback
  from torch.optim import Adam
  from torch.utils.data import DataLoader
  from tests.helpers.models.torch_model import TorchNormalModel_Classification_1
  from tests.helpers.datasets.torch_data import TorchArgMaxDataset
label_desc: Use image node_id 1 for calling a global function with example usage: test_trainer_deepspeed(device, callbacks, strategy, config, n_epochs) without return types