  We extend the definition of L\"uscher's lattice topological charge to the
case of $4$d $SU(N)$ gauge fields coupled with $\mathbb{Z}_N$ $2$-form gauge
fields. This result is achieved while maintaining the locality, the $SU(N)$
gauge invariance, and $\mathbb{Z}_N$ $1$-form gauge invariance, and we find
that the manifest $1$-form gauge invariance plays the central role in our
construction. This result gives the lattice regularized derivation of the mixed
't Hooft anomaly in pure $SU(N)$ Yang-Mills theory between its $\mathbb{Z}_N$
$1$-form symmetry and the $\theta$ periodicity.
