  We give the best known pseudorandom generators for two touchstone classes in
unconditional derandomization: an $\varepsilon$-PRG for the class of size-$M$
depth-$d$ $\mathsf{AC}^0$ circuits with seed length $\log(M)^{d+O(1)}\cdot
\log(1/\varepsilon)$, and an $\varepsilon$-PRG for the class of $S$-sparse
$\mathbb{F}_2$ polynomials with seed length $2^{O(\sqrt{\log S})}\cdot
\log(1/\varepsilon)$. These results bring the state of the art for
unconditional derandomization of these classes into sharp alignment with the
state of the art for computational hardness for all parameter settings:
improving on the seed lengths of either PRG would require breakthrough progress
on longstanding and notorious circuit lower bounds.
  The key enabling ingredient in our approach is a new \emph{pseudorandom
multi-switching lemma}. We derandomize recently-developed
\emph{multi}-switching lemmas, which are powerful generalizations of
H{\aa}stad's switching lemma that deal with \emph{families} of depth-two
circuits. Our pseudorandom multi-switching lemma---a randomness-efficient
algorithm for sampling restrictions that simultaneously simplify all circuits
in a family---achieves the parameters obtained by the (full randomness)
multi-switching lemmas of Impagliazzo, Matthews, and Paturi [IMP12] and
H{\aa}stad [H{\aa}s14]. This optimality of our derandomization translates into
the optimality (given current circuit lower bounds) of our PRGs for
$\mathsf{AC}^0$ and sparse $\mathbb{F}_2$ polynomials.
