\newcommand{\drawgridrectangle}[4]{%
  \begin{tikzpicture}[scale=#4]
    \pgfmathsetmacro{\ymax}{#1}
    \pgfmathsetmacro{\xmax}{#2}

    % Fill the rectangle
    \fill[#3] (0,0) rectangle (\xmax,\ymax);

    % Draw the border
    \draw[white, line width=#4*3pt] (0,0) rectangle (\xmax,\ymax);

    % Draw vertical grid lines
    \pgfmathsetmacro{\xsteps}{#2}
    \foreach \x in {1,...,\xsteps} {
      \draw[white, line width=#4*3pt] (\x,0) -- (\x,\ymax);
    }

    % Draw horizontal grid lines
    \pgfmathsetmacro{\ysteps}{#1}
    \foreach \y in {1,...,\ysteps} {
      \draw[white, line width=#4*7pt] (0,\y) -- (\xmax,\y);
    }
  \end{tikzpicture}%
}

\centering
\newsavebox{\visualAbstract}
\savebox{\visualAbstract}{
  \begin{tikzpicture}
    % ===================================================================
    % DRAW VECTORS OF DERIVATIVES 0, 1, ..., K
    % ===================================================================
    \matrix [%
    matrix of nodes,%
    ampersand replacement=\&,% to use inside a savebox
    nodes={anchor=center, align=center},%
    column sep=5ex,%
    row sep=1ex,%
    ] (taylor)
    {
      \drawgridrectangle{1}{5}{gray!25!white}{0.33}
      \& \drawgridrectangle{1}{3}{gray!25!white}{0.33}
      \& \drawgridrectangle{1}{1}{gray!25!white}{0.33}
      \\[-1.5ex]
      $\vx_0$ \& $\vh_0$ \& $\vg_0$
      \\
      \drawgridrectangle{4}{5}{gray!50!white}{0.33}
      \& \drawgridrectangle{4}{3}{gray!50!white}{0.33}
      \& \drawgridrectangle{4}{1}{gray!50!white}{0.33}
      \\[-1.5ex]
      $\{\vx_{1, r}\}$ \& $\{\vh_{1, r}\}$ \& $\{\vg_{1, r}\}$
      \\[0.5ex]
      \drawgridrectangle{1}{5}{white}{0.33}
      \& \drawgridrectangle{1}{3}{white}{0.33}
      \& \drawgridrectangle{1}{1}{white}{0.33}
      \\[0.5ex]
      \\
      \drawgridrectangle{4}{5}{gray!75!white}{0.33}
      \& \drawgridrectangle{4}{3}{gray!75!white}{0.33}
      \& \drawgridrectangle{4}{1}{gray!75!white}{0.33}
      \\[-1.5ex]
      $\{\vx_{K-1, r}\}$ \& $\{\vh_{K-1, r}\}$ \& $\{\vg_{K-1, r}\}$
      \\[0.5ex]
      \drawgridrectangle{4}{5}{tab-orange}{0.33}
      \&
      \drawgridrectangle{4}{3}{tab-orange}{0.33}
      \&
      \drawgridrectangle{4}{1}{tab-orange}{0.33}
      \\[-1.5ex]
      $\{\vx_{K, r}\}$ \& $\{\vh_{K,r}\}$ \& $\{\vg_{K,r}\}$
      \\
      \drawgridrectangle{1}{5}{tab-green}{0.33}
      \& \drawgridrectangle{1}{3}{tab-green}{0.33}
      \& \drawgridrectangle{1}{1}{tab-green}{0.33}
      \\[-1ex]
      \textcolor{tab-green}{$\sum_r \vx_{K,r}$}
      \& \textcolor{tab-green}{$\sum_r \vh_{K,r}$}
      \& \textcolor{tab-green}{$\sum_r \vg_{K,r}$}
      \\
    };

    \node at (taylor-5-1) {\vdots};
    \node at (taylor-5-2) {\vdots};
    \node at (taylor-5-3) {\vdots};

    % ===================================================================
    % DRAW DEPENDENCY ARROWS
    % ===================================================================
    \pgfmathsetmacro{\K}{5}
    \pgfmathsetmacro{\L}{2}

    \foreach \l in {1,...,\L}{
      \pgfmathsetmacro{\lother}{int(\l+1)}
      \foreach \k in {1,...,\K} {
        \pgfmathsetmacro{\row}{int(2*\k-1)}
        \foreach \kother in {\k,...,\K} {
          \pgfmathsetmacro{\rowother}{int(2*\kother-1)}
          \draw[-Stealth, line width=1pt, gray!50!white] (taylor-\row-\l.east) -- (taylor-\rowother-\lother.west);
        }
      }
    }

    % ===================================================================
    % DRAW ARROW INDICATING DIRECTION OF PROPAGATION
    % ===================================================================
    \coordinate (arrowStart) at ($(taylor-1-1.north)+(0,3.5ex)$);
    \coordinate (arrowEnd) at ($(taylor-1-3.north east)+(0,3.5ex)$);
    \draw[-Stealth, line width=2pt, black] (arrowStart) to node [midway, fill=white, align=center] {\textbf{Taylor forward} \\ \textbf{propagation}} (arrowEnd);

    % ===================================================================
    % DRAW DERIVATIVE DEGREE LABELS
    % ===================================================================
    \node [minimum width=8ex, align=center, left=1.5ex of taylor-1-1] (zero) {0};
    \node [minimum width=8ex, align=center, left=1.5ex of taylor-3-1] {1};
    \node [minimum width=8ex, align=center, left=1.5ex of taylor-5-1] {$\vdots$};
    \node [minimum width=8ex, align=center, left=1.5ex of taylor-7-1] {$K-1$};
    \node [minimum width=8ex, align=center, left=1.5ex of taylor-9-1] {$K$};
    \node [minimum width=8ex, align=center, left=1.5ex of taylor-11-1, yshift=-8pt] {$K$ \\ \textbf{(ours)}};

    \node [align=center] (coefficientLabel) at ($(zero)+(0, 5.5ex)$) {\textbf{Derivative}\\\textbf{degree}};

    % ===================================================================
    % DRAW THE RED BOX HIGHLIGHTING THE HIGHEST COMPONENT
    % ===================================================================
    \draw[rounded corners, line width=2pt, red] (taylor-9-1.north west) rectangle (taylor-10-3.south east);
    \draw[white, fill=white] ($(taylor-10-3.south east)+(-0.3ex, 2ex)$) rectangle ($(taylor-10-3.south east)+(0.3ex, 11.25ex)$);

    \draw [-Stealth, line width=1.25pt, red]
    ($(taylor-10-3.south east)+(0, 2.75ex)$)
    -- ($(taylor-10-3.south east)+(0, 5.75ex)$);

    \draw [-Stealth, line width=1.25pt, red]
    ($(taylor-10-3.south east)+(0, 10.5ex)$)
    -- ($(taylor-10-3.south east)+(0, 7.5ex)$);
    ;

    \draw [red, line width=5pt]
    ($(taylor-10-3.south east)+(-0.7ex, 6.625ex)$)
    -- ($(taylor-10-3.south east)+(0.7ex, 6.625ex)$);
  \end{tikzpicture}
}

\resizebox{\linewidth}{!}{
  \begin{tikzpicture}
    \node {\usebox{\visualAbstract}};
  \end{tikzpicture}
}

%%% Local Variables:
%%% mode: LaTeX
%%% TeX-master: "../main"
%%% End:
