def data_parallel(module, input, device_ids, output_device=None):
 if (not device_ids):
  return module(input)
 if (output_device is None):
  output_device = device_ids[0]
 replicas = replicate(module, device_ids)
 inputs = scatter(input, device_ids)
 replicas = replicas[:len(inputs)]
 outputs = parallel_apply(replicas, inputs)
 return gather(outputs, output_device)

def data_parallel ( module , input , device_ids , output_device = None ) : if ( not device_ids ) : return module ( input ) if ( output_device is None ) : output_device = device_ids [ 0 ] replicas = replicate ( module , device_ids ) inputs = scatter ( input , device_ids ) replicas = replicas [ : len ( inputs ) ] outputs = parallel_apply ( replicas , inputs ) return gather ( outputs , output_device )
evaluates module in parallel across the gpus given in device_ids .