def METHOD_NAME(target: np.ndarray, preds: np.ndarray, top_k: Optional[int] = None):
    """Adapting `from sklearn.metrics.ndcg_score`."""
    assert target.shape == preds.shape
    assert len(target.shape) == 1  # works only with single dimension inputs
    if target.shape[0] < 2:  # ranking is equal to ideal ranking with a single document
        return np.array(1.0)
    preds = np.expand_dims(preds, axis=0)
    target = np.expand_dims(target, axis=0)
    return ndcg_score(target, preds, k=top_k)