code: def test_tacotron2_multi_gpu_trainable(model_dict):
      ngpu = 2
      device_ids = list(range(ngpu))
      device = torch.device("cuda")
      bs = 10
      maxin_len = 10
      maxout_len = 10
      idim = 5
      odim = 10
      model_args = make_taco2_args(**model_dict)
      batch = prepare_inputs(
          bs,
          idim,
          odim,
          maxin_len,
          maxout_len,
          model_args["spk_embed_dim"],
          model_args["spc_dim"],
          device=device,
      )
  
      # define model
      model = Tacotron2(idim, odim, Namespace(**model_args))
      model = torch.nn.DataParallel(model, device_ids)
      optimizer = torch.optim.Adam(model.parameters())
      model.to(device)
  
      # trainable
      loss = model(**batch).mean()
      optimizer.zero_grad()
      loss.backward()
      optimizer.step()
  
file_path: espnet/test/test_e2e_tts_tacotron2.py
imports: from __future__ import division, print_function
  from argparse import Namespace
  import numpy
  import pytest
  import torch
  from espnet.nets.pytorch_backend.e2e_tts_tacotron2 import Tacotron2
  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_tacotron2_multi_gpu_trainable(model_dict) without return types