def METHOD_NAME(self, params):
    """Test that the correct cost is returned via the step_and_cost method for the
    Rotoselect momentum optimizer"""
    rotoselect_opt = RotoselectOptimizer()
    generators = [qml.RY, qml.RX]
    possible_generators = [qml.RX, qml.RY, qml.RZ]
    rotoselect_opt.possible_generators = possible_generators
    dev = qml.device("default.qubit", shots=None, wires=2)
    def ansatz(params, generators):
        generators[0](params[0], wires=0)
        generators[1](params[1], wires=1)
        qml.CNOT(wires=[0, 1])
    @qml.qnode(dev)
    def circuit_1(params, generators=None):  # generators will be passed as a keyword arg
        ansatz(params, generators)
        return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliY(1))
    @qml.qnode(dev)
    def circuit_2(params, generators=None):  # generators will be passed as a keyword arg
        ansatz(params, generators)
        return qml.expval(qml.PauliX(0))
    def cost_fn(params, generators):
        Z_1, Y_2 = circuit_1(params, generators=generators)
        X_1 = circuit_2(params, generators=generators)
        return 0.5 * Y_2 + 0.8 * Z_1 - 0.2 * X_1
    _, _, res = rotoselect_opt.step_and_cost(cost_fn, params, generators)
    expected = cost_fn(params, generators)
    assert np.all(res == expected)