def _make_lookup_predict_fn(existing_predictions: tuple[np.ndarray, np.ndarray], fuzzy_float_compare: bool) -> Callable:
    """
    Makes a predict_fn callback based on a table of existing predictions.

    :param existing_predictions: Tuple of (samples, labels).
    :param fuzzy_float_compare: Look up predictions using `np.isclose`, only set to True if really needed, since this
                                severely affects performance.
    :return: Prediction function.
    """

    samples, labels = existing_predictions

    if fuzzy_float_compare:
        from sortedcontainers import SortedList

        # Construct a search-tree of the predictions, using fuzzy float comparison
        sorted_predictions = SortedList([FuzzyMapping(key, value) for key, value in zip(samples, labels)])

        def fuzzy_predict_fn(batch):
            predictions = []
            for row in batch:
                try:
                    match_idx = sorted_predictions.index(FuzzyMapping(row))
                except ValueError as err:  # pragma: no cover
                    raise ValueError("No existing prediction for queried input") from err

                predictions.append(sorted_predictions[match_idx].value)

            return np.array(predictions)

        return fuzzy_predict_fn

    # Construct a dictionary to map from samples to predictions. We use the bytes of the `ndarray` as the key,
    # because the `ndarray` itself is not hashable
    mapping = {}
    for x, y in zip(samples, labels):
        mapping[x.tobytes()] = y

    def predict_fn(batch):
        predictions = []
        for row in batch:
            row_bytes = row.tobytes()
            if row.tobytes() not in mapping:
                raise ValueError("No existing prediction for queried input")

            predictions.append(mapping[row_bytes])

        return np.array(predictions)

    return predict_fn

    Makes a predict_fn callback based on a table of existing predictions.

    :param existing_predictions: Tuple of (samples, labels).
    :param fuzzy_float_compare: Look up predictions using `np.isclose`, only set to True if really needed, since this
                                severely affects performance.
    :return: Prediction function.
    
art/estimators/classification/blackbox.py