code: def test_transformer_multi_gpu_trainable(model_dict):
      # make args
      model_args = make_transformer_args(**model_dict)
  
      # setup batch
      idim = 5
      odim = 10
      ilens = [10, 5]
      olens = [20, 15]
      device = torch.device("cuda")
      batch = prepare_inputs(
          idim,
          odim,
          ilens,
          olens,
          model_args["spk_embed_dim"],
          device=device,
      )
  
      # define model
      ngpu = 2
      device_ids = list(range(ngpu))
      model = Transformer(idim, odim, Namespace(**model_args))
      model = torch.nn.DataParallel(model, device_ids)
      model.to(device)
      optimizer = torch.optim.Adam(model.parameters())
  
      # trainable
      loss = model(**batch).mean()
      optimizer.zero_grad()
      loss.backward()
      optimizer.step()
  
      # check gradient of ScaledPositionalEncoding
      if model.module.use_scaled_pos_enc:
          assert model.module.encoder.embed[1].alpha.grad is not None
          assert model.module.decoder.embed[1].alpha.grad is not None
  
file_path: espnet/test/test_e2e_tts_transformer.py
imports: from argparse import Namespace
  import numpy
  import pytest
  import torch
  from espnet.nets.pytorch_backend.e2e_tts_transformer import Transformer, subsequent_mask
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 6 for calling a global function with example usage: test_transformer_multi_gpu_trainable(model_dict) without return types