def __contains__(self, item: raw_types.Gate | raw_types.Operation) -> bool:
        r"""Check for containment of a given Gate/Operation in this Gateset.

        Containment checks are handled as follows:

        - For Gates or Operations that have an underlying gate (i.e. op.gate is not None):
            - Forwards the containment check to the underlying `cirq.GateFamily` objects.
            - Examples of such operations include `cirq.GateOperation`s and their controlled
                and tagged variants (i.e. instances of `cirq.TaggedOperation`,
                `cirq.ControlledOperation` where `op.gate` is not None) etc.
        - For Operations that do not have an underlying gate:
            - Forwards the containment check to `self._validate_operation(item)`.
            - Examples of such operations include `cirq.CircuitOperation`s and their controlled
                and tagged variants (i.e. instances of `cirq.TaggedOperation`,
                `cirq.ControlledOperation` where `op.gate` is None) etc.

        The complexity of the method in terms of the number of `gates`, n, is

        - O(1) when any default `cirq.GateFamily` instance accepts the given item, except
            for an Instance GateFamily trying to match an item with a different global phase.
        - O(n) for all other cases: matching against custom gate families, matching across
            global phase for the default Instance GateFamily, no match against any underlying
            gate family.

        Args:
            item: The `cirq.Gate` or `cirq.Operation` instance to check containment for.
        """
        if isinstance(item, raw_types.Operation) and item.gate is None:
            return self._validate_operation(item)

        g = item if isinstance(item, raw_types.Gate) else item.gate
        assert g is not None, f'`item`: {item} must be a gate or have a valid `item.gate`'

        if g in self._instance_gate_families:
            assert item in self._instance_gate_families[g], (
                f"{item} instance matches {self._instance_gate_families[g]} but "
                f"is not accepted by it."
            )
            return True

        for gate_mro_type in type(g).mro():
            if gate_mro_type in self._type_gate_families:
                assert item in self._type_gate_families[gate_mro_type], (
                    f"{g} type {gate_mro_type} matches Type GateFamily:"
                    f"{self._type_gate_families[gate_mro_type]} but is not accepted by it."
                )
                return True

        return any(item in gate_family for gate_family in self._gates)
Check for containment of a given Gate/Operation in this Gateset.

        Containment checks are handled as follows:

        - For Gates or Operations that have an underlying gate (i.e. op.gate is not None):
            - Forwards the containment check to the underlying `cirq.GateFamily` objects.
            - Examples of such operations include `cirq.GateOperation`s and their controlled
                and tagged variants (i.e. instances of `cirq.TaggedOperation`,
                `cirq.ControlledOperation` where `op.gate` is not None) etc.
        - For Operations that do not have an underlying gate:
            - Forwards the containment check to `self._validate_operation(item)`.
            - Examples of such operations include `cirq.CircuitOperation`s and their controlled
                and tagged variants (i.e. instances of `cirq.TaggedOperation`,
                `cirq.ControlledOperation` where `op.gate` is None) etc.

        The complexity of the method in terms of the number of `gates`, n, is

        - O(1) when any default `cirq.GateFamily` instance accepts the given item, except
            for an Instance GateFamily trying to match an item with a different global phase.
        - O(n) for all other cases: matching against custom gate families, matching across
            global phase for the default Instance GateFamily, no match against any underlying
            gate family.

        Args:
            item: The `cirq.Gate` or `cirq.Operation` instance to check containment for.
        
cirq-core/cirq/ops/gateset.py