This is an exact equation.
An equation
$$A(x,y) dx + B(x,y)dy=0$$
is called exact if there is a function $F(x,y)$ such that
$$A(x,y)=\frac{\partial F}{\partial x}\qquad\text{and}\qquad B(x,y)=\frac{\partial F}{\partial y} \qquad\text{(Equations $1, 2$)}$$
In that case, the general solution of the differential equation then has the shape
$$F(x,y)=C, \qquad\text{where $C$ is any constant}.$$
From any given initial condition, $C$ can be determined. In general, from $F(x,y)=C$ you will not be able to determine $y$ explicitly in terms of $x$.
In your problem, we have $A(x,y)=2xy^2+\cos x$ and $B(x,y)=2x^2y+\sin y$. We wish to find a function $F(x,y)$ such that Equations $1$ and $2$ hold.
Right now, you have no assurance that there is such a function $F(x,y)$, except for my assertion that the equation is exact. Later, I will give a criterion that enables you to test for exactness before embarking on a possibly fruitless quest for a $F(x,y)$ that satisfies Equations $1$ and $2$.
But for now, let's look for such a $F(x,y)$. Remember, we are using partial derivatives.
So we want $F(x,y)$ to be kind of an integral of $2xy^2+\cos x$ with respect to $x$, where $y$ is treated as a constant.
Integrate in the usual way. What should $F(x,y)$ look like?
We get $F(x,y)=x^2y^2 +\sin x$, sort of. But remember that $y$ is being treated as a constant, so the general integral of $2xy^2+\cos x$ with respect to $x$ has shape
$$F(x,y)=x^2y^2 + \sin x + a(y) \qquad (3)$$
where $a(y)$ is any function of $y$. This is because when we take the partial derivative of this with respect to $x$, the $a(y)$ is treated as a constant and disappears.
Now let's find a general formula for $F(x,y)$ such that the partial derivative of $F(x,y)$ with respect to $y$ is $2x^2y+\sin y$. By the same reasoning as before, we should have
$$F(x,y)=x^2y^2 -\cos y +b(x) \qquad (4)$$
where $b(x)$ is any function of $x$.
Now look at ($3$) and ($4$). How can we make them exactly the same?
You can see that we need $a(y)=-\cos y$ and $b(x)=\sin x$.
So an $F(x,y)$ that works is given by
$$F(x,y)=x^2y^2+ \sin x -\cos y$$
It follows that the general solution of your differential equation is
$$x^2y^2 +\sin x -\cos y=C$$
It is absolutely hopeless to solve this implicit equation explicitly for $y$ in terms of $x$.
You can check whether your answer is a solution to the original DE by calculating the derivative of $F(x,y)$ with respect to $x$. This time, be sure to use the implicit differentiation that you learned in calculus classes.
A Test for Exactness: The equation
$$A(x,y) dx + B(x,y)dy=0$$
is exact precisely if
$$\frac{\partial A}{\partial y}=\frac{\partial B}{\partial x}$$
(This follows from the fact that mixed partials are equal).
So before you embark on the search for $F(x,y)$, you might as well use the simple test above to check whether such an $F(x,y)$ exists. (Partial) differentiation is generally easy, so testing for exactness doesn't take much time. Check whether our $A(x,y)$ and $B(x,y)$ pass the test. This really should have been done at the beginning, but I was in a hurry to get to the solution.