Assume I have a quantum register made of $N$ qubits.
Assume I want to compute the inner product
$$ \langle \psi|I_{n_y} \otimes A_{n_x}| \psi \rangle . $$
Note that I am using statevetor simulations for the moment. Here, the state $\psi$ has dimension $2^N$, the identity matrix $I_{n_y}$ has a side of length $n_y$ and the matrix $A_{n_x}$ has a side of length $n_x$, with $2^N = n_x n_y$. Assume that I have already the circuit computing
$$ \langle \psi'|A_{n_x}|\psi' \rangle , $$
where $\psi'$ is a quantum register of $n_x$ qubits.
How do I compute $\langle \psi|I_{n_y}\otimes A_{n_x}|\psi \rangle $?
Extra: what about $\langle \psi | A_{n_y} \otimes I_{n_x}|\psi \rangle $?