Solution (source code)

= Solution

Take $m=\lceil(b-a)/\varepsilon\rceil$. The ceiling, as printed in the PDF, makes the intervals cover the bounded range of f. If $a=b$, use the single set $\mathcal X$ instead, since f is constant. By <continuity> their preimages are closed. On every nonempty preimage $C_i$, the oscillation of f is at most epsilon. Hence for every $y\in C_i$,
$$
\sup_{C_i}f\leq f(y)+\varepsilon,\qquad\sup_{C_i}f-I(y)\leq\sup_{x\in\mathcal X}(f(x)-I(x))+\varepsilon.
$$
Taking the <supremum> over y in the second expression gives the bound for $\sup_{C_i}f-\inf_{C_i}I$; if that <infimum> is infinite, the bound is automatic. Apply the finite-cover estimate to obtain
$$
\boxed{\limsup_n n^{-1}\log\mathbb E e^{nf(X_n)}\leq\sup_x(f(x)-I(x))+\varepsilon.}
$$
This is the exponential-integral upper estimate in the bounded form of <Varadhan lemma>.