def compute_differences(X, pairs):
    """Compute differences between pairs of elements

Parameters
----------
X: 2d array, shape (n_samples, n_features)
    The data array

pairs: 2d array, shape (n_pairs, 2)
    Pair of element indices

Returns
-------
diff: 2d array, shape (n_pairs, n_features)
    ``diff[i] = X[pairs[i, 0]] - X[pairs[i, 1]]``
"""
    return X[pairs[:, 0]] - X[pairs[:, 1]]