def test_bipartite_matching_op():
    def assert_match(inputs, x, y, threshold, is_ascend=False):
        for dtype in ['float16', 'float32', 'float64']:
            inputs = mx.nd.array(inputs, dtype=dtype)
            x = np.array(x, dtype=dtype)
            y = np.array(y, dtype=dtype)
            a, b = mx.nd.contrib.bipartite_matching(inputs, threshold=threshold, is_ascend=is_ascend)
            assert_array_equal(a.asnumpy().astype('int64'), x.astype('int64'))
            assert_array_equal(b.asnumpy().astype('int64'), y.astype('int64'))
    assert_match([[0.5, 0.6], [0.1, 0.2], [0.3, 0.4]], [1, -1, 0], [2, 0], 1e-12, False)
    assert_match([[0.5, 0.6], [0.1, 0.2], [0.3, 0.4]], [-1, 0, 1], [1, 2], 100, True)