Repository: PennyLaneAI/pennylane

Issue:
[BUG] The documentation for the QNG Optimizer includes a deprecated item.
### Expected behavior

The [documentation for the QNG Optimizer](https://docs.pennylane.ai/en/stable/code/api/pennylane.QNGOptimizer.html) doesn't use deprecated functions.



### Actual behavior

The [documentation for the QNG Optimizer](https://docs.pennylane.ai/en/stable/code/api/pennylane.QNGOptimizer.html) includes a reference to ExpvalCost in the first example. This should be changed for the new way of using the optimizer since expval doesn't work as-is for the example.

### Additional information

_No response_

### Source code

```shell
import pennylane as qml

dev = qml.device("default.qubit", wires=1)
def circuit(params, wires=0):
    qml.RX(params[0], wires=wires)
    qml.RY(params[1], wires=wires)
coeffs = [1, 1]
obs = [qml.PauliX(0), qml.PauliZ(0)]
H = qml.Hamiltonian(coeffs, obs)
cost_fn = qml.ExpvalCost(circuit, H, dev)
```


### Tracebacks

```shell
/opt/conda/envs/pennylane/lib/python3.9/site-packages/pennylane/vqe/vqe.py:154: UserWarning: ExpvalCost is deprecated, use qml.expval() instead. For optimizing Hamiltonian measurements with measuring commuting terms in parallel, use the grouping_type keyword in qml.Hamiltonian.
  warnings.warn(
```


### System information

```shell
Name: PennyLane
Version: 0.25.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /opt/conda/envs/pennylane/lib/python3.9/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Cirq, PennyLane-Lightning, PennyLane-Lightning-GPU, PennyLane-qiskit, pennylane-qulacs, PennyLane-SF

Platform info:           Linux-5.4.196-108.356.amzn2.x86_64-x86_64-with-glibc2.31
Python version:          3.9.13
Numpy version:           1.23.2
Scipy version:           1.9.0
Installed devices:
- lightning.gpu (PennyLane-Lightning-GPU-0.24.1)
- default.gaussian (PennyLane-0.25.0)
- default.mixed (PennyLane-0.25.0)
- default.qubit (PennyLane-0.25.0)
- default.qubit.autograd (PennyLane-0.25.0)
- default.qubit.jax (PennyLane-0.25.0)
- default.qubit.tf (PennyLane-0.25.0)
- default.qubit.torch (PennyLane-0.25.0)
- default.qutrit (PennyLane-0.25.0)
- lightning.qubit (PennyLane-Lightning-0.25.0)
- cirq.mixedsimulator (PennyLane-Cirq-0.24.0)
- cirq.pasqal (PennyLane-Cirq-0.24.0)
- cirq.qsim (PennyLane-Cirq-0.24.0)
- cirq.qsimh (PennyLane-Cirq-0.24.0)
- cirq.simulator (PennyLane-Cirq-0.24.0)
- qiskit.aer (PennyLane-qiskit-0.24.0)
- qiskit.basicaer (PennyLane-qiskit-0.24.0)
- qiskit.ibmq (PennyLane-qiskit-0.24.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.24.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.24.0)
- qulacs.simulator (pennylane-qulacs-0.24.0)
- strawberryfields.fock (PennyLane-SF-0.20.1)
- strawberryfields.gaussian (PennyLane-SF-0.20.1)
- strawberryfields.gbs (PennyLane-SF-0.20.1)
- strawberryfields.remote (PennyLane-SF-0.20.1)
- strawberryfields.tf (PennyLane-SF-0.20.1)
```


### Existing GitHub issues

- [X] I have searched existing GitHub issues to make sure the issue does not already exist.


Discussion:
Thanks for finding this @CatalinaAlbornoz ! I'll open a PR momementarily.

Resolving patch:
diff --git a/pennylane/optimize/qng.py b/pennylane/optimize/qng.py
--- a/pennylane/optimize/qng.py
+++ b/pennylane/optimize/qng.py
@@ -75,11 +75,11 @@ class QNGOptimizer(GradientDescentOptimizer):
 
     .. note::
 
-        The QNG optimizer supports single QNodes or :class:`~.ExpvalCost` objects as objective functions.
-        Alternatively, the metric tensor can directly be provided to the :func:`step` method of the optimizer,
-        using the ``metric_tensor_fn`` argument.
+        The QNG optimizer supports using a single :class:`~.QNode` as the objective function. Alternatively,
+        the metric tensor can directly be provided to the :func:`step` method of the optimizer,
+        using the ``metric_tensor_fn`` keyword argument.
 
-        For the following cases, providing metric_tensor_fn may be useful:
+        For the following cases, providing ``metric_tensor_fn`` may be useful:
 
         * For hybrid classical-quantum models, the "mixed geometry" of the model
           makes it unclear which metric should be used for which parameter.
@@ -90,28 +90,17 @@ class QNGOptimizer(GradientDescentOptimizer):
         * For multi-QNode models, we don't know what geometry is appropriate
           if a parameter is shared amongst several QNodes.
 
-        If the objective function is VQE/VQE-like, i.e., a function of a group
-        of QNodes that share an ansatz, there are two ways to use the optimizer:
-
-        * Realize the objective function as an :class:`~.ExpvalCost` object, which has
-          a ``metric_tensor`` method.
-
-        * Manually provide the ``metric_tensor_fn`` corresponding to the metric tensor of
-          of the QNode(s) involved in the objective function.
-
     **Examples:**
 
     For VQE/VQE-like problems, the objective function for the optimizer can be
-    realized as an ExpvalCost object.
+    realized as :class:`~.QNode` that returns the expectation value of a Hamiltonian.
 
-    >>> dev = qml.device("default.qubit", wires=1)
-    >>> def circuit(params, wires=0):
-    ...     qml.RX(params[0], wires=wires)
-    ...     qml.RY(params[1], wires=wires)
-    >>> coeffs = [1, 1]
-    >>> obs = [qml.PauliX(0), qml.PauliZ(0)]
-    >>> H = qml.Hamiltonian(coeffs, obs)
-    >>> cost_fn = qml.ExpvalCost(circuit, H, dev)
+    >>> dev = qml.device("default.qubit", wires=(0, 1, "aux"))
+    >>> @qml.qnode(dev)
+    ... def circuit(params):
+    ...     qml.RX(params[0], wires=0)
+    ...     qml.RY(params[1], wires=0)
+    ...     return qml.expval(qml.PauliX(0) + qml.PauliX(1))
 
     Once constructed, the cost function can be passed directly to the
     optimizer's ``step`` function:
@@ -119,22 +108,18 @@ class QNGOptimizer(GradientDescentOptimizer):
     >>> eta = 0.01
     >>> init_params = np.array([0.011, 0.012])
     >>> opt = qml.QNGOptimizer(eta)
-    >>> theta_new = opt.step(cost_fn, init_params)
-    >>> print(theta_new)
-    [0.011445239214543481, -0.027519522461477233]
-
-    Alternatively, the same objective function can be used for the optimizer
-    by manually providing the ``metric_tensor_fn``.
-
-    >>> qnodes = qml.map(circuit, obs, dev, 'expval')
-    >>> cost_fn = qml.dot(coeffs, qnodes)
-    >>> eta = 0.01
-    >>> init_params = np.array([0.011, 0.012])
-    >>> opt = qml.QNGOptimizer(eta)
-    >>> metric_tensor_fn = qml.metric_tensor(qnodes.qnodes[0], approx='block-diag')
-    >>> theta_new = opt.step(cost_fn, init_params, metric_tensor_fn=metric_tensor_fn)
-    >>> print(theta_new)
-    [0.011445239214543481, -0.027519522461477233]
+    >>> theta_new = opt.step(circuit, init_params)
+    >>> theta_new
+    tensor([ 0.01100528, -0.02799954], requires_grad=True)
+
+    An alternative function to calculate the metric tensor of the QNode
+    can be provided to :meth:`~.step`
+    via the ``metric_tensor_fn`` keyword argument.  For example, we can provide a function
+    to calculate the metric tensor via the adjoint method.
+
+    >>> adj_metric_tensor = qml.adjoint_metric_tensor(circuit, circuit.device)
+    >>> opt.step(circuit, init_params, metric_tensor_fn=adj_metric_tensor)
+    tensor([ 0.01100528, -0.02799954], requires_grad=True)
 
     .. seealso::
 


Test patch: