  We perform a systematic study on the local and global spin polarization of
$\Lambda$ and $\overline{\Lambda}$ hyperons in relativistic heavy-ion
collisions at beam energy scan energies via the (3+1)-dimensional CLVisc
hydrodynamics model with AMPT and SMASH initial conditions. Following the
quantum kinetic theory, we decompose the polarization vector as the parts
induced by thermal vorticity, shear tensor and the spin Hall effect (SHE). We
find that the polarization induced by SHE and the total polarization strongly
depends on the initial conditions. At $7.7$GeV, SHE gives a sizeable
contribution and even flips the sign of the local polarization along the beam
direction for AMPT initial condition, which is not observed for SMASH initial
condition. Meanwhile, the local polarization along the out-of-plane direction
induced by SHE with AMPT initial condition does not always increase with
decreasing collision energies. Next, we find that the polarization along the
beam direction is sensitive to the baryon diffusion coefficient, but the local
polarization along the out-of-plane direction is not. Our results for the
global polarization of $\Lambda$ and $\overline{\Lambda}$ agree well with the
STAR data. Interestingly, the global polarization of $\overline{\Lambda}$ is
not always larger than that of $\Lambda$ due to various competing effects. Our
findings are helpful for understanding the polarization phenomenon and the
detailed structure of quark-gluon plasma in relativistic heavy-ion collisions.
