code: def depth(self, local: bool = True) -> int:
          
          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
docs: Return the circuit depth.
  
          Args:
              local:  If True include local one-qubit gates in depth
                  calculation. Else return the multi-qubit gate depth.