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

    # get the location in the circuit and the element to insert from choices
    randrange = _randrange(seed)
    loc = randrange(len(circuit) + 1)
    choice = choices[randrange(len(choices))]

    circuit = list(circuit)
    circuit[loc: loc] = choice
    return tuple(circuit)

# Flatten the GateIdentity objects (with gate rules) into one single list
Called when new progress information should be reported.
dataset/ETHPy150Open sympy/sympy/sympy/physics/quantum/circuitutils.py/random_insert--crossover with--dataset/ETHPy150Open ganeti/ganeti/lib/masterd/instance.py/ImportExportCbBase.ReportProgress