It works

  
      github.com
  
  
    pytorch/pytorch/blob/master/torch/nn/parallel/_functions.py#L6 17

import torch
import torch.cuda.comm as comm
from torch.autograd import Function




class Broadcast(Function):


@staticmethod
def forward(ctx, target_gpus, *inputs):
    if not all(input.is_cuda for input in inputs):
        raise TypeError('Broadcast function not implemented for CPU tensors')
    ctx.target_gpus = target_gpus
    if len(inputs) == 0:
        return tuple()
    ctx.num_inputs = len(inputs)
    ctx.input_device = inputs[0].get_device()