You could use the default_collate as a starter and just add your random slicing into your custom collate function.
Here is a small example for your use case:
from torch._six import container_abcs

class MyDataset(Dataset):
    def __init__(self, data):
        self.data = data
        self.target = torch.zeros(data.size(0))
        
    def __getitem__(self, index):
        x = self.data[index]
        y = self.target[index]
        return x, y
    
    def __len__(self):
        return len(self.data)

def my_collate(batch):
    if isinstance(batch[0], torch.Tensor):
        if batch[0].dim() == 4:
            batch = [b[torch.randint(0, K, (1,))].squeeze() for b in batch]
        return torch.stack(batch, 0)
    if isinstance(batch[0], container_abcs.Sequence):
        transposed = zip(*batch)
        return [my_collate(samples) for samples in transposed]

N, K, C, H, W = 10, 5, 3, 4, 4
batch_size=2
data = torch.randn(N, K, C, H, W)
dataset = MyDataset(data)
loader = DataLoader(
    dataset,
    num_workers=0,
    batch_size=batch_size,
    shuffle=True,
    collate_fn=my_collate
)

for x, y in loader:
    print(x.shape)

Note that I just implemented the collate function for data with 4 dimensions and a scalar target.
If your target has the same dimensions as your data, this won’t work.
Let me know, if that’s the case.