def block_overlapping_deprecation(match_regex: str):
    """Context to block deprecation warnings raised within it.

    Useful if a function call might raise more than one warning,
    where only one warning is desired.

    Args:
        match_regex: DeprecationWarnings with message fields matching
            match_regex will be blocked.
    """
    with warnings.catch_warnings():
        warnings.filterwarnings(
            action='ignore', category=DeprecationWarning, message=f'(.|\n)*{match_regex}(.|\n)*'
        )
        yield
Context to block deprecation warnings raised within it.

    Useful if a function call might raise more than one warning,
    where only one warning is desired.

    Args:
        match_regex: DeprecationWarnings with message fields matching
            match_regex will be blocked.
    
cirq-core/cirq/_compat.py