Overview.
You're familiar with MLE, which is a good starting point. We have a parametric model whose parameters $\theta$ we seek to optimize, in order to maximize the likelihood of our model $L(\theta \mid \{y_1,y_2,...,y_n\}) = p_Y(\{y_1,y_2,...,y_n\} \mid \theta)$. Gradient-based methods are one way to do the optimization.
It's no different with normalizing flows: we're trying to maximize the likelihood. The transformation $f$ has some parameters $\theta$ that we seek to optimize, possibly with gradient ascent. (The prior distribution on $x$, $p_X$, may have its own parameters $\phi$ to learn. Or we could just declare it to be a standard Gaussian with the same dimension as $Y$ or something. This means that only $f$ has learnable parameters.) These parameters are just like any other.
About $f$.
The transformation $f$ must have three important properties that we will use in a moment. It is deterministic; it is invertible; and it has an easily computable, easily differentiable determinant of the Jacobian. Some example functions satisfying these requirements are here.
Computing the likelihood.
Mechanically, how would you compute $p_Y(y_i \mid \theta)$? Remember that $p_Y(y_i \mid \theta) = p_X\left(f^{-1}_\theta(y_i)\right) \cdot \left|\det \left(\frac{\mathrm{d}f^{-1}_\theta}{\mathrm{d}x}\right)\right|$. (Your question was missing the $\det$.)
- Apply the inverse transform of your observed variable $y_i$ to compute the latent variable $x_i = f^{-1}_\theta(y_i)$.
- Compute the probability density $p_X(x_i)$.
- Compute the $\left|\det \left(\frac{\mathrm{d}f^{-1}_\theta}{\mathrm{d}x}\right)\right|$ term. This is easy because of the functional form we chose.
- Multiply these terms to get the likelihood.
Learning $\theta$.
To actually learn $\theta$ with gradient descent requires finding and following the gradient. I'll suggest a way assuming you're working in a computing toolkit that supports reverse-mode automatic differentiation (back-propagation). There are other options as well; heck, you could define the gradients by hand if you hate yourself want to.
- Backpropagate from the negative log of the likelihood to compute gradients with respect to $\theta$.
- Adjust $\theta$ by taking a step in the direction down the gradient.