Collect tensors from DistributedSampler

I use DistributedSampler to sample from the dataset for distributed training. However, I need to gather the distributed tensors to evaluate. How to achieve that?