def compare_with_metrics(x1, x2, metric_fns, distinguish_incomparable=False):
    """Compare two points x1 and x2 by calling an element of metric_fns
    for each coordinate.
    If a metric_fn is None, then ignore the coordinate.

    By default, return -1 if x1 is strictly less, 1 if x1 is strictly greater,
    and 0 if the points are equal or unordered.

    If distinguish_incomparable is True,
    only return 0 for points that are equal;
    for unordered but not equal ("incomparable") points return None instead.
    """
    lt = False
    gt = False
    for a1, a2, cmp_lt in zip(x1, x2, metric_fns):
        if cmp_lt is not None:
            if cmp_lt(a1, a2):
                lt = True
                if gt:
                    break
            elif cmp_lt(a2, a1):
                gt = True
                if lt:
                    break

    if lt:
        if gt:
            if distinguish_incomparable:
                return None
            else:
                return 0
        else: # not gt
            return -1

    else: # not lt
        if gt:
            return 1
        else: # not gt
            return 0