def _invertible_else_1(a: int, m: int) -> int:
    """Returns `a` if `a` has a multiplicative inverse, else 1."""
    i = _mod_inv_else_1(a, m)
    return a if i != 1 else i
Returns `a` if `a` has a multiplicative inverse, else 1.
cirq-core/cirq/interop/quirk/cells/arithmetic_cells.py