def extend_back(self, dag, edge_map=None):
edge_map = edge_map or {}<EOL>for qreg in dag.qregs.values():<EOL><INDENT>if qreg.name not in self.qregs:<EOL><INDENT>self.add_qreg(QuantumRegister(qreg.size, qreg.name))<EOL><DEDENT>edge_map.update([(qbit, qbit) for qbit in qreg if qbit not in edge_map])<EOL><DEDENT>for creg in dag.cregs.values():<EOL><INDENT>if creg.name not in self.cregs:<EOL><INDENT>self.add_creg(ClassicalRegister(creg.size, creg.name))<EOL><DEDENT>edge_map.update([(cbit, cbit) for cbit in creg if cbit not in edge_map])<EOL><DEDENT>self.compose_back(dag, edge_map)<EOL>
Add `dag` at the end of `self`, using `edge_map`.