The generic Chernoff bound for a random variable $X$ is attained by applying Markov's inequality to $e^{t X}$. For positive $t$ this gives a bound on the right tail of $X$ in terms of its moment-generating function $M(t)=\mathrm{E}\left(e^{t X}\right)$ :
$$
\mathrm{P}(X \geq nq)=\mathrm{P}\left(e^{t X} \geq e^{t nq}\right) \leq M(t) e^{-t nq} \quad(t>0)
$$
Since this bound holds for every positive $t$, we may take the infimum:
$$
\mathrm{P}(X \geq nq) \leq \inf _{t>0} M(t) e^{-t nq}
$$
When $X$ is the sum of $n$ independent random variables $X_1, \ldots, X_n$, the moment generating function of $X$ is the product of the individual moment generating functions, giving that:
$$
\operatorname{Pr}(X \geq nq) \leq \inf _{t>0} \frac{\mathrm{E}\left[\prod_{i=1}^n e^{t \cdot X_i}\right]}{e^{t \cdot nq}}=\inf _{t>0} e^{-t \cdot nq} \prod_{i=1}^n \mathrm{E}\left[e^{t \cdot X_i}\right]
$$
Now,
$$\mathrm{E}\left[e^{t \cdot X_i}\right]=\left(1-p_i\right) e^0+p_i e^t$$
$$
\operatorname{Pr}(X \geq nq) \leq \inf _{t>0} e^{-t \cdot nq} \prod_{i=1}^n \left( p_i e^t+(1-p_i)\right)
$$
Let,
$$a= \prod_{i=1}^n \left( p_i e^t+(1-p_i)\right)\\b=(\bar{p}e^t+(1-\bar{p}))^n.$$ where $ \bar{p}=\frac{1}{n}\sum_{i=1}^np_i$,$0\leq p_i\leq 1,t>0,n\in \mathbb{Z^+}$
\begin{align}
\log(a)
&= \log \left ( \prod_{i=1}^n (p_ie^t + (1-p_i)) \right ) \\
&= \sum_{i=1}^n \log (p_ie^t + 1 - p_i) \\
&= n \sum_{i=1}^n \frac{1}{n} \log(p_i e^t + 1 - p_i) \\
&\leq n \log \left ( \sum_{i=1}^n \frac{1}{n} (p_ie^t + 1-p_i) \right ) \\
&= n \log (\bar{p}e^t + 1 - \bar{p}) \\
&= \log \left ( (\bar{p}e^t + (1- \bar{p}))^n \right ) = \log(b)
\end{align}
where the inequality is a consequence of Jensen's inequality and the fact that $\log$ is concave. relevant answer
Then
$$
\operatorname{Pr}(X \geq nq) \leq \inf _{t>0} e^{-t \cdot nq} a\leq \inf _{t>0} e^{-t \cdot nq} b= \inf _{t>0} e^{-t \cdot nq}(\bar{p}e^t+(1-\bar{p}))^n
$$
$$
\operatorname{Pr}(X \geq nq) \leq \inf _{t>0}\left(\bar{p} e^{(1-q) t}+(1-\bar{p}) e^{-q t}\right)^n
$$
Therefore, we can easily compute the infimum, using calculus:
$$
\frac{d}{d t}\left(\bar{p} e^{(1-q) t}+(1-\bar{p}) e^{-q t}\right)=(1-q) \bar{p} e^{(1-q) t}-q(1-\bar{p}) e^{-q t}
$$
Setting the equation to zero and solving, we have
$$
\begin{aligned}
(1-q) \bar{p} e^{(1-q) t} & =q(1-\bar{p}) e^{-q t} \\
(1-q) \bar{p} e^t & =q(1-\bar{p})
\end{aligned}
$$
so that
$$
e^t=\frac{(1-\bar{p}) q}{(1-q) \bar{p}}
$$
Thus,
$$
t=\log \left(\frac{(1-\bar{p}) q}{(1-q)\bar{p}}\right)
$$
Setting $q=\bar{p}+\varepsilon>\bar{p}$, we see that $t>0$, so our bound is satisfied on $t$. Having solved for $t$, we can plug back into the equations above to find that
$$
\begin{aligned}
\log \left(\bar{p} e^{(1-q) t}+(1-\bar{p}) e^{-q t}\right) & =\log \left(e^{-q t}\left(1-\bar{p}+\bar{p} e^t\right)\right) \\
& =\log \left(e^{-q \log \left(\frac{(1-\bar{p}) q}{(1-q) \bar{p}}\right)}\right)+\log \left(1-\bar{p}+\bar{p} e^{\log \left(\frac{1-\bar{p}}{1-q}\right)} e^{\log \frac{q}{\bar{p}}}\right) \\
& =-q \log \frac{1-\bar{p}}{1-q}-q \log \frac{q}{\bar{p}}+\log \left(1-\bar{p}+\bar{p}\left(\frac{1-\bar{p}}{1-q}\right) \frac{q}{\bar{p}}\right) \\
& =-q \log \frac{1-\bar{p}}{1-q}-q \log \frac{q}{\bar{p}}+\log \left(\frac{(1-\bar{p})(1-q)}{1-q}+\frac{(1-\bar{p}) q}{1-q}\right) \\
& =-q \log \frac{q}{\bar{p}}+\left(-q \log \frac{1-\bar{p}}{1-q}+\log \frac{1-\bar{p}}{1-q}\right) \\
& =-q \log \frac{q}{\bar{p}}+(1-q) \log \frac{1-\bar{p}}{1-q} \\
& =-D(q \| \bar{p}) .
\end{aligned}
$$
Finally,
$$\operatorname{Pr}\left(\frac{1}{n} \sum X_i \geq \bar{p}+\varepsilon\right) \leq e^{-D(\bar{p}+\varepsilon \| \bar{p}) n}$$