willychan21's picture
Upload folder using huggingface_hub
c2f8cf1 verified
import torch
import torch.distributed as dist
@torch.no_grad()
def solution(tensor: torch.Tensor) -> torch.Tensor:
world_size = dist.get_world_size()
out = tensor.new_empty((world_size,) + tensor.shape)
dist.all_gather_into_tensor(out, tensor)
return out