Example 12 Given $0<x<\frac{\pi}{2}, a, b$ are positive real numbers, $m$, $n \in \mathbf{N}_{+}$, find the minimum value of the function $y=\frac{a}{\sin ^{n} x}+\frac{b}{\cos n x}$. (Example 5 from [5])
$$\begin{array}{l}
\text { Prove } y=\frac{a}{\sin ^{\frac{n}{} x}}+\frac{b}{\cos ^{n} x} \\
=\frac{\left(a^{\frac{2 m}{n+2 m}}\right)^{\frac{n+2 m}{2 m}}}{\left(\sin ^{2} x\right)^{\frac{n}{2 m}}}+\frac{\left(b^{\frac{2 m}{n+2 m}} \frac{n+2 m}{2 m}\right.}{\left(\cos ^{2} x\right)^{\frac{n}{2 m}}} \\
\geqslant \frac{\left(a^{\frac{2 m}{n+2 m}}+b \frac{2 m}{n+2 m}\right)^{\frac{n+2 m}{2 m}}}{\left(\sin ^{2} x+\cos ^{2} x\right)^{\frac{n}{2 m}}} \\
=\left(a^{\frac{2 m}{n+2 m}}+b^{\frac{2 m}{n+2 m}}\right)^{\frac{n+2 m}{2 m}} \text {, }
\end{array}$$

When and only when $\frac{a^{\frac{2 m}{n+2 m}}}{\sin ^{2} x}=\frac{b^{\frac{2 m}{n+2 m}}}{\cos ^{2} x}$, i.e., $x=$ $\arctan \sqrt[n+2 m]{\left(\frac{a}{b}\right)^{m}}$, the equality holds. Therefore, the minimum value of the function $y=\frac{a}{\sin ^{n} x}+$ $\frac{b}{\cos m x}$ is $\left(a^{\frac{2 m}{2 m+n}}+b^{\frac{2 m}{2 m+n}}\right)^{\frac{2 m+n}{2 m}}$.