def METHOD_NAME(self, pids, output='packed'):
    permute_idxs, unordered_tensors, unordered_lengths, unordered_masks = self.lookup_packed_unordered(pids)
    output_tensor = torch.empty(permute_idxs.size(0), self.max_stride, *self.inner_dims,
                                dtype=unordered_tensors[0].dtype, device=unordered_tensors[0].device)
    output_mask = torch.zeros(permute_idxs.size(0), self.max_stride,
                              dtype=unordered_masks[0].dtype, device=unordered_masks[0].device)
    offset = 0
    for tensor, mask in zip(unordered_tensors, unordered_masks):
        endpos = offset + tensor.size(0)
        output_tensor[offset:endpos, :tensor.size(1)] = tensor
        output_mask[offset:endpos, :mask.size(1)] = mask
        offset = endpos
    output_mask = output_mask[permute_idxs]
    output_tensor = output_tensor[permute_idxs]
    if output == 'padded':
        return output_tensor, output_mask
    assert output == 'packed'
    output_tensor = output_tensor[output_mask]
    return output_tensor, unordered_lengths[permute_idxs]