Sizing parentheses around tikzpicture

You can use baseline key

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\[ \left( \begin{tikzpicture}[scale=0.2,baseline=-1mm] 
\draw [magenta, line width=1mm] (0,-1) rectangle (4,3); 
\draw [magenta, line width=1mm] (4,-1) rectangle (6,-3); 
\end{tikzpicture} \right)
\]

\end{document}

enter image description here


Using the comment by @greg and the answers of Align an equation and a tikz picture with anchor and baseline, I would in this case use:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}

\begin{document}

\[ A = \left(\,
        \begin{tikzpicture}[scale=0.2, 
                baseline={([yshift=-\the\dimexpr\fontdimen22\textfont2\relax]
                    current bounding box.center)},
        ] 
            \draw [magenta, line width =1mm] (0,-1) rectangle (4,3); 
            \draw [magenta, line width=1mm] (4,-1) rectangle (6,-3); 
        \end{tikzpicture} 
    \,\right)
\]

\end{document}

...to center the center of the figure with the = sign, and I would add a bit of space \, around the figure.

Result