def with_debug(value: bool) -> Iterator[None]:
    """Sets the value of global constant `cirq.__cirq_debug__` within the context.

    If `__cirq_debug__` is set to False, all validations in Cirq are disabled to optimize
    performance. Users should use the `cirq.with_debug` context manager instead of manually
    mutating the value of `__cirq_debug__` flag. On exit, the context manager resets the
    value of `__cirq_debug__` flag to what it was before entering the context manager.
    """
    token = __cirq_debug__.set(value)
    try:
        yield
    finally:
        __cirq_debug__.reset(token)
Sets the value of global constant `cirq.__cirq_debug__` within the context.

    If `__cirq_debug__` is set to False, all validations in Cirq are disabled to optimize
    performance. Users should use the `cirq.with_debug` context manager instead of manually
    mutating the value of `__cirq_debug__` flag. On exit, the context manager resets the
    value of `__cirq_debug__` flag to what it was before entering the context manager.
    
cirq-core/cirq/_compat.py