def METHOD_NAME(self, pids):
    pids, lengths, offsets = self._prepare_lookup(pids)
    lengths2 = lengths.clone()
    sentinel = self.strides[-1] + 1
    order = torch.arange(pids.size(0), device='cuda' if self.use_gpu else 'cpu')
    all_orders = []
    all_tensors = []
    all_lengths = []
    all_masks = []
    for stride in self.strides:
        is_shorter = lengths2 <= stride
        if is_shorter.sum() == 0:
            continue
        order_ = order[is_shorter]
        tensor_, lengths_, mask_ = self._lookup_with_stride(stride, lengths[is_shorter], offsets[is_shorter])
        all_orders.append(order_)
        all_tensors.append(tensor_)
        all_lengths.append(lengths_)
        all_masks.append(mask_)
        lengths2[is_shorter] = sentinel
    assert lengths2.allclose(torch.tensor([sentinel], device='cuda' if self.use_gpu else 'cpu'))
    all_orders = torch.cat(all_orders)
    permute_idxs = torch.sort(all_orders).indices
    return permute_idxs, all_tensors, torch.cat(all_lengths), all_masks