<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def depth(self, local: bool = True) -> int: """Return the circuit depth. Args: local: If True include local one-qubit gates in depth calculation. Else return the multi-qubit gate depth. """

        G = self.graph
        if not local:
            def remove_local(dagc: DAGCircuit) \
                    -> Generator[Operation, None, None]:
                for elem in dagc:
                    if dagc.graph.degree[elem] > 2:
                        yield elem
            G = DAGCircuit(remove_local(self)).graph

        return nx.dag_longest_path_length(G) - 1