When is is safe to return cuda tensors in a data loaders/datasets/samplers/collate_fn?

When is it safe to return gpu/cuda tensors. e.g. may I return it in my collate function after I collate everything into 1 tensor?

In that case do we still need to do pin_memory=True?