Bernoulli's theorem holds for incompressible, non-viscous fluids. How is this relationship changed when the viscosity of the fluid is not negligible?

If the viscosity of the fluid is not negligible, a part of the mechanical energy of the fluid is spent in doing work against forces of viscosity.
So the total energy: