def pytest_collection_modifyitems(config, items):
    """
    Modifies the test items so that items marked optional are skipped
    when the --runopt command line option is not provided.
    Otherwise, will not perform any modifications.
    """

    # No modifications required
    if config.getoption("--runopt"):
        return

    skip_opt = pytest.mark.skip(reason="need --runopt option to run")

    for item in items:
        markers = marker_names(item)
        if "optional" in markers:
            item.add_marker(skip_opt)

    Modifies the test items so that items marked optional are skipped
    when the --runopt command line option is not provided.
    Otherwise, will not perform any modifications.
    
coremltools/test/optimize/torch/conftest.py