def random_insert(circuit, choices, seed=None):
 from sympy.utilities.randtest import _randrange
 if (not choices):
  return circuit
 if isinstance(circuit, Mul):
  circuit = circuit.args
 randrange = _randrange(seed)
 loc = randrange((len(circuit) + 1))
 choice = choices[randrange(len(choices))]
 circuit = list(circuit)
 circuit[loc:loc] = choice
 return tuple(circuit)

def random_insert ( circuit , choices , seed = None ) : from sympy . utilities . randtest import _randrange if ( not choices ) : return circuit if isinstance ( circuit , Mul ) : circuit = circuit . args randrange = _randrange ( seed ) loc = randrange ( ( len ( circuit ) + 1 ) ) choice = choices [ randrange ( len ( choices ) ) ] circuit = list ( circuit ) circuit [ loc : loc ] = choice return tuple ( circuit )
insert a circuit into another quantum circuit .