def METHOD_NAME(Q, D_padded, D_mask, config=ColBERTConfig()):
    """
        Supply sizes Q = (1 | num_docs, *, dim) and D = (num_docs, *, dim).
        If Q.size(0) is 1, the matrix will be compared with all passages.
        Otherwise, each query matrix will be compared against the *aligned* passage.
        EVENTUALLY: Consider masking with -inf for the maxsim (or enforcing a ReLU).
    """
    use_gpu = config.total_visible_gpus > 0
    if use_gpu:
        Q, D_padded, D_mask = Q.cuda(), D_padded.cuda(), D_mask.cuda()
    assert Q.dim() == 3, Q.size()
    assert D_padded.dim() == 3, D_padded.size()
    assert Q.size(0) in [1, D_padded.size(0)]
    scores = D_padded @ Q.to(dtype=D_padded.dtype).permute(0, 2, 1)
    return colbert_score_reduce(scores, D_mask, config)