docstr: Do the forward pass using multiple GPUs.  This is a simplification
  of torch.nn.parallel.data_parallel to support the allennlp model
  interface.
docstr_tok: ["Do","the","forward","pass","using","multiple","GPUs",".","This","is","a","simplification","of","torch.nn.parallel.data_parallel","to","support","the","allennlp","model","interface","."]
code: def _data_parallel(self, batch):
      """
      Do the forward pass using multiple GPUs.  This is a simplification
      of torch.nn.parallel.data_parallel to support the allennlp model
      interface.
      """
      inputs, module_kwargs = scatter_kwargs(
          (), batch, self._cuda_devices, 0
      )
      used_device_ids = self._cuda_devices[: len(inputs)]
      replicas = replicate(self._model, used_device_ids)
      outputs = parallel_apply(
          replicas, inputs, module_kwargs, used_device_ids
      )
  
      # Only the 'loss' is needed.
      # a (num_gpu, ) tensor with loss on each GPU
      losses = gather(
          [output["loss"].unsqueeze(0) for output in outputs],
          used_device_ids[0],
          0,
      )
      return {"loss": losses.mean()}
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import logging
  import os
  import shutil
  import time
  import re
  import datetime
  import traceback
  import torch
  import torch.optim.lr_scheduler
  from torch.nn.parallel import replicate, parallel_apply
  from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import peak_memory_mb, gpu_memory_mb
  from allennlp.common.tqdm import Tqdm
  from allennlp.data.instance import Instance
  from allennlp.data.iterators.data_iterator import DataIterator
  from allennlp.models.model import Model
  from allennlp.nn import util
  from allennlp.training.learning_rate_schedulers import LearningRateScheduler
  from allennlp.training.optimizers import Optimizer
label_desc: Use image node_id 5 for calling the Trainer obj's underlying member method code with example usage: obj._data_parallel(batch) and returns: dict