def retry_once_after_timeout(testfunc: Callable) -> Callable:
    """Marks a test function for one retry if it fails with TimeoutError.

    This decorator is intended for test functions which occasionally fail
    with TimeoutError.
    """

    @functools.wraps(testfunc)
    def wrapped_func(*args, **kwargs) -> Any:
        try:
            return testfunc(*args, **kwargs)
        except TimeoutError:
            pass
        warnings.warn("Retrying in case we have a transitive TimeoutError")
        return testfunc(*args, **kwargs)

    return wrapped_func
Marks a test function for one retry if it fails with TimeoutError.

    This decorator is intended for test functions which occasionally fail
    with TimeoutError.
    
cirq-core/cirq/testing/pytest_utils.py