Split DAGCircuit into layers, where the operations within each
        layer operate on different qubits (and therefore commute).

        Returns: A Circuit of Circuits, one Circuit per layer

def layers(self) -> Circuit:
        """Split DAGCircuit into layers, where the operations within each
        layer operate on different qubits (and therefore commute).

        Returns: A Circuit of Circuits, one Circuit per layer
        """
        node_depth: Dict[Qubit, int] = {}
        G = self.graph

        for elem in self:
            depth = np.max(list(node_depth.get(prev, -1) + 1
                           for prev in G.predecessors(elem)))
            node_depth[elem] = depth

        depth_nodes = invert_map(node_depth, one_to_one=False)

        layers = []
        for nd in range(0, self.depth()):
            elements = depth_nodes[nd]
            circ = Circuit(list(elements))
            layers.append(circ)

        return Circuit(layers)