def gather(self, dst: int=0, out: Optional[torch.Tensor]=None) -> None:
    '\n        Creates a full :class:`Tensor` on rank ``dst`` by gathering all shards of the\n        sharded tensor.\n\n        The API needs to be called on all ranks in SPMD fashion. All ranks should have\n        the same ``dst``. ``out`` should be a tensor of the same size as the overall\n        size of the sharded tensor on ``dst`` and ``None`` on all other ranks.\n\n        Args:\n            dst(int): The rank where full tensor is constructed.\n                Default: 0\n            out (:class `torch.Tensor`, optional): The output full tensor.\n                Must to be provided ONLY on ``dst`` rank.\n                Default: ``None``\n        '
    rank = dist.get_rank(self._process_group)
    full_size = self.metadata().size
    _validate_output_tensor_for_gather(rank, dst, full_size, out)
    local_shards = self.local_shards()
    world_size = dist.get_world_size(self._process_group)
    gathered_shards = ([None] * world_size)
    dist.all_gather_object(obj=local_shards, object_list=gathered_shards, group=self._process_group)
    if (rank == dst):
        dims = len(full_size)
        for shards in gathered_shards:
            if (shards is None):
                raise RuntimeError('Gathered shards cannot be None on dst rank {dst}')
            for shard in shards:
                metadata = shard.metadata
                tensor = shard.tensor
                out_narrow_view = out
                for dim in range(dims):
                    out_narrow_view = out_narrow_view.narrow(dim, metadata.shard_offsets[dim], metadata.shard_sizes[dim])
                out_narrow_view.copy_(tensor)
Creates a full :class:`Tensor` on rank ``dst`` by gathering all shards of the
sharded tensor.

The API needs to be called on all ranks in SPMD fashion. All ranks should have
the same ``dst``. ``out`` should be a tensor of the same size as the overall
size of the sharded tensor on ``dst`` and ``None`` on all other ranks.

Args:
    dst(int): The rank where full tensor is constructed.
        Default: 0
    out (:class `torch.Tensor`, optional): The output full tensor.
        Must to be provided ONLY on ``dst`` rank.
        Default: ``None``
def gather(self, dst: int=0, out: Optional[torch.Tensor]=None) -> None:
    '\n        Creates a full :class:`Tensor` on rank ``dst`` by gathering all shards of the\n        sharded tensor.\n\n        The API needs to be called on all ranks in SPMD fashion. All ranks should have\n        the same ``dst``. ``out`` should be a tensor of the same size as the overall\n        size of the sharded tensor on ``dst`` and ``None`` on all other ranks.\n\n        Args:\n            dst(int): The rank where full tensor is constructed.\n                Default: 0\n            out (:class `torch.Tensor`, optional): The output full tensor.\n                Must to be provided ONLY on ``dst`` rank.\n                Default: ``None``\n        '
    rank = dist.get_rank(self._process_group)
    full_size = self.metadata().size
    _validate_output_tensor_for_gather(rank, dst, full_size, out)
    local_shards = self.local_shards()
    world_size = dist.get_world_size(self._process_group)
    gathered_shards = ([None] * world_size)
    dist.all_gather_object(obj=local_shards, object_list=gathered_shards, group=self._process_group)
    if (rank == dst):
        dims = len(full_size)
        for shards in gathered_shards:
            if (shards is None):
                raise RuntimeError('Gathered shards cannot be None on dst rank {dst}')
            for shard in shards:
                metadata = shard.metadata
                tensor = shard.tensor
                out_narrow_view = out
                for dim in range(dims):
                    out_narrow_view = out_narrow_view.narrow(dim, metadata.shard_offsets[dim], metadata.shard_sizes[dim])
                out_narrow_view.copy_(tensor)