\documentclass[10pt,aspectratio=169]{beamer}
\usepackage{tikz}
\usetikzlibrary{spy}
\tikzset{
invisible/.style={opacity=0},
visible on/.style={alt={#1{}{invisible}}},
highlight on/.style={alt={#1{fill=darkred!80!black}{fill=gray!30!white}}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\begin{tikzpicture}[%
spy using outlines={rectangle, magnification=4, size=2cm, connect spies},