def METHOD_NAME(
    qubits, betas, gammas, graph, use_boolean_hamiltonian_gate
):  # Nodes should be integers
    if use_boolean_hamiltonian_gate:
        booleans = [f"x{i} ^ x{j}" for i, j in sorted(graph.edges)]
        param_names = [f"x{i}" for i in range(len(qubits))]
        for beta, gamma in zip(betas, gammas):
            yield cirq.BooleanHamiltonianGate(param_names, booleans, 2.0 * gamma).on(*qubits)
            yield cirq.rx(2 * beta).on_each(*qubits)
    else:
        for beta, gamma in zip(betas, gammas):
            yield (rzz(-0.5 * gamma).on(qubits[i], qubits[j]) for i, j in graph.edges)
            yield cirq.rx(2 * beta).on_each(*qubits)