def clean_up_backends(
    backends: List[BackendConfig],
    minimum_opset_version: ct.target,
    force_include_iOS15_test: bool = False,
) -> List[BackendConfig]:
    """
    Given a list of BackendConfig objects, this utility function filters out the invalid elements.

    For instance, given a list of configs with opset_versions range from iOS14 to iOS17, with minimum_opset_version set to iOS16 and environment variable `RUN_BACKWARD_COMAPTIBILITY=1`, iOS14/iOS15 configs are removed, and iOS16/iOS17 configs are preserved.

    To be more specific, the config is removed if one of the following conditions is matched:
    1. If opset_version is not compatible with the macOS.
    2. If opset_version < minimum_opset_version
    3. For the non backward compatibility run, opset_version > minimum_opset_version

    Note a corner case that when `force_include_iOS15_test=True`, the iOS15 configs are forced to be preserved.
    """
    test_all_opset_versions = os.getenv("RUN_BACKWARD_COMPATIBILITY") == "1"
    res = []
    for config in backends:
        # First check if the macOS are able to run the test
        if not macos_compatible_with_deployment_target(config.opset_version):
            continue
        if force_include_iOS15_test and config.opset_version == ct.target.iOS15:
            res.append(config)
            continue
        if config.opset_version < minimum_opset_version:
            continue
        if not test_all_opset_versions and config.opset_version > minimum_opset_version:
            continue
        res.append(config)

    if len(res) == 0:
        pytest.skip(
            f"Tests are not runnable under {minimum_opset_version.name}.", allow_module_level=True
        )

    return res

    Given a list of BackendConfig objects, this utility function filters out the invalid elements.

    For instance, given a list of configs with opset_versions range from iOS14 to iOS17, with minimum_opset_version set to iOS16 and environment variable `RUN_BACKWARD_COMAPTIBILITY=1`, iOS14/iOS15 configs are removed, and iOS16/iOS17 configs are preserved.

    To be more specific, the config is removed if one of the following conditions is matched:
    1. If opset_version is not compatible with the macOS.
    2. If opset_version < minimum_opset_version
    3. For the non backward compatibility run, opset_version > minimum_opset_version

    Note a corner case that when `force_include_iOS15_test=True`, the iOS15 configs are forced to be preserved.
    
coremltools/converters/mil/testing_reqs.py