\documentclass[margin=2pt]{standalone}

\usepackage{amsmath,amsfonts,bm}
\usepackage{booktabs}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{calc,fit}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{snakes}
\usetikzlibrary{patterns}

\begin{document}
\begin{tikzpicture}[every node/.style={inner sep=0pt}, var/.style={draw=black, minimum size=15pt, circle, font=\small, thick, anchor=center}, factor/.style={fill=black, minimum size=5pt, rectangle, anchor=center}, edge/.style={thick, -latex}, modulation/.style={thick, -|}, zlabel/.style={font=\scriptsize, yshift=-2pt}, observed/.style={fill=gray!30}, flowlabel/.style={midway, font=\scriptsize}, rewardlabel/.style={pos=1, font=\scriptsize, right}, gfn_edge/.style={ultra thick, -latex}, gfn_node/.style={ultra thick, circle, draw}, gfn_other/.style={pos=1, anchor=west, inner sep=2pt}, adjacency/.style={minimum width=10pt, minimum height=10pt, rectangle, rounded corners=2pt, font=\bfseries\scriptsize}, mini adjacency/.style={minimum width=5pt, minimum height=5pt, rectangle, rounded corners=1pt}, container/.style={inner sep=5pt, rounded corners=2pt, thick, fill=gray!10, draw=black, thick}, y=12pt, x=50pt]

\tikzset{
diagonal fill/.style 2 args={fill=#2, path picture={
\fill[#1, sharp corners] (path picture bounding box.south west) -|
                         (path picture bounding box.north east) -- cycle;}},
reversed diagonal fill/.style 2 args={fill=#2, path picture={
\fill[#1, sharp corners] (path picture bounding box.north west) |- 
                         (path picture bounding box.south east) -- cycle;}}
}

\node[] (model) at (0, 0) {\begin{tikzpicture}

\node[] (graph_t) {\begin{tikzpicture}
    \node[var] (A) {$A$};
    \node[var, above right=1em and 0.5em of A] (B) {$B$};
    \node[var, below right=1em and 0.5em of B] (C) {$C$};
    
    \draw[edge] (A) -- (B);
\end{tikzpicture}};
\node[below=0.5em of graph_t] (graph_t_label) {$G_{t}$};

\node[above=7em of graph_t, container] (mask_t) {\begin{tikzpicture}
    \node[adjacency, fill=black] (AA) {};
    \node[adjacency, fill=black, right=1pt of AA] (AB) {};
    \node[adjacency, fill=gray!30, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=black, below=1pt of AA] (BA) {};
    \node[adjacency, fill=black, right=1pt of BA] (BB) {};
    \node[adjacency, fill=gray!30, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!30, right=1pt of CA] (CB) {};
    \node[adjacency, fill=black, right=1pt of CB] (CC) {};
\end{tikzpicture}};
\node[above=0.5em of mask_t] (mask_t_label) {$\bm{m}_{t}$};

\node[below=2em of mask_t, container] (mask_t_dec) {\begin{tikzpicture}
    \node[adjacency, fill=LimeGreen] (AA) {};
    \node[adjacency, fill=Magenta, right=1pt of AA] (AB) {};
    \node[adjacency, fill=gray!30, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=LimeGreen, below=1pt of AA] (BA) {};
    \node[adjacency, fill=LimeGreen, right=1pt of BA] (BB) {};
    \node[adjacency, fill=gray!30, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!30, right=1pt of CA] (CB) {};
    \node[adjacency, fill=LimeGreen, right=1pt of CB] (CC) {};
\end{tikzpicture}};


% \node[right=5em of mask_t] (mask_t_) {\begin{tikzpicture}
%     \node[adjacency, fill=NavyBlue, text=white] (AA) {$0$};
%     \node[adjacency, fill=NavyBlue, right=1pt of AA, text=white] (AB) {$0$};
%     \node[adjacency, diagonal fill={Red!20}{NavyBlue!20}, right=1pt of AB] (AC) {$1$};
    
%     \node[adjacency, fill=black, below=1pt of AA, text=white] (BA) {$0$};
%     \node[adjacency, fill=black, right=1pt of BA, text=white] (BB) {$0$};
%     \node[adjacency, fill=Red!20, right=1pt of BB] (BC) {$1$};
    
%     \node[adjacency, fill=gray!20, below=1pt of BA] (CA) {$1$};
%     \node[adjacency, below=1pt of BA, draw=ForestGreen, very thick] (CA_) {};
%     \node[adjacency, fill=gray!20, right=1pt of CA] (CB) {$1$};
%     \node[adjacency, fill=Red, right=1pt of CB, text=white] (CC) {$0$};
    
%     % \node[fit=(AA)(AB)(AC), draw=NavyBlue, very thick, rounded corners=2pt] {};
%     % \node[fit=(AC)(BC)(CC), draw=ForestGreen, very thick, rounded corners=2pt] {};
% \end{tikzpicture}};

\node[right=5em of mask_t, container] (mask_t_) {\begin{tikzpicture}
    \node[adjacency, fill=gray!20] (AA) {};
    \node[adjacency, fill=Magenta, right=1pt of AA] (AB) {};
    \node[adjacency, fill=gray!30, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of AA] (BA) {};
    \node[adjacency, fill=gray!30, right=1pt of BA] (BB) {};
    \node[adjacency, fill=gray!30, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!30, right=1pt of CA] (CB) {};
    \node[adjacency, fill=gray!30, right=1pt of CB] (CC) {};
\end{tikzpicture}};

\node[container, xshift=-3em] (mask_t_dec_1) at (mask_t_dec -| mask_t_) {\begin{tikzpicture}
    \node[adjacency, fill=LimeGreen] (AA) {};
    \node[adjacency, fill=gray!30, right=1pt of AA] (AB) {};
    \node[adjacency, fill=gray!30, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=LimeGreen, below=1pt of AA] (BA) {};
    \node[adjacency, fill=LimeGreen, right=1pt of BA] (BB) {};
    \node[adjacency, fill=gray!30, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!30, right=1pt of CA] (CB) {};
    \node[adjacency, fill=LimeGreen, right=1pt of CB] (CC) {};
\end{tikzpicture}};

\node[container, xshift=3em] (mask_t_dec_2) at (mask_t_dec -| mask_t_) {\begin{tikzpicture}
    \node[adjacency, fill=NavyBlue] (AA) {};
    \node[adjacency, fill=gray!30, right=1pt of AA] (AB) {};
    \node[adjacency, fill=gray!30, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=NavyBlue, below=1pt of AA] (BA) {};
    \node[adjacency, fill=LimeGreen, right=1pt of BA] (BB) {};
    \node[adjacency, fill=gray!30, right=1pt of BB] (BC) {};

    \node[adjacency, diagonal fill={Red!20}{NavyBlue!20}, below=1pt of BA] (CA) {};
    \node[adjacency, fill=Red!20, right=1pt of CA] (CB) {};
    \node[adjacency, fill=Red, right=1pt of CB] (CC) {};
\end{tikzpicture}};

% \node[] (graph_t_) at (graph_t -| mask_t_) {\begin{tikzpicture}
%     \node[var] (A) {$A$};
%     \node[var, above right=1em and 0.5em of A] (B) {$B$};
%     \node[var, below right=1em and 0.5em of B] (C) {$C$};
    
%     \draw[edge] (A) -- (B);
%     \draw[edge, ForestGreen] (C) -- (A);
% \end{tikzpicture}};

\node[right=10em of mask_t_, container] (mask_tp1_) {\begin{tikzpicture}
    \node[adjacency, fill=gray!20] (AA) {};
    \node[adjacency, fill=Magenta, right=1pt of AA] (AB) {};
    \node[adjacency, fill=gray!30, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of AA] (BA) {};
    \node[adjacency, fill=gray!30, right=1pt of BA] (BB) {};
    \node[adjacency, fill=gray!30, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=Dandelion, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!30, right=1pt of CA] (CB) {};
    \node[adjacency, fill=gray!30, right=1pt of CB] (CC) {};
\end{tikzpicture}};

\node[container] (mask_tp1_dec_) at (mask_t_dec_2 -| mask_tp1_) {\begin{tikzpicture}
    \node[adjacency, fill=LimeGreen] (AA) {};
    \node[adjacency, fill=gray!30, right=1pt of AA] (AB) {};
    \node[adjacency, fill=Purple, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=LimeGreen, below=1pt of AA] (BA) {};
    \node[adjacency, fill=LimeGreen, right=1pt of BA] (BB) {};
    \node[adjacency, fill=Purple, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=gray!30, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!30, right=1pt of CA] (CB) {};
    \node[adjacency, fill=LimeGreen, right=1pt of CB] (CC) {};
\end{tikzpicture}};

\coordinate (mid) at ($(mask_t_dec)!0.5!(mask_t_dec_1)$);
\draw[rounded corners=2pt, edge] (mask_t_dec) -- (mid) |- (mask_t_);
\draw[edge] (mask_t_dec) -- (mask_t_dec_1);
\draw[edge] (mask_t_dec_1) -- (mask_t_dec_2);

\node[] (graph_tp1_) at (graph_t -| mask_tp1_) {\begin{tikzpicture}
    \node[var, NavyBlue] (A) {$A$};
    \node[var, above right=1em and 0.5em of A] (B) {$B$};
    \node[var, Red, below right=1em and 0.5em of B] (C) {$C$};
    
    \draw[edge] (A) -- (B);
    \draw[edge, Dandelion] (C) -- (A);
\end{tikzpicture}};

\node[right=5em of mask_tp1_, container] (mask_tp1) {\begin{tikzpicture}
    \node[adjacency, fill=black] (AA) {};
    \node[adjacency, fill=black, right=1pt of AA] (AB) {};
    \node[adjacency, fill=black, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=black, below=1pt of AA] (BA) {};
    \node[adjacency, fill=black, right=1pt of BA] (BB) {};
    \node[adjacency, fill=black, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=black, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!20, right=1pt of CA] (CB) {};
    \node[adjacency, fill=black, right=1pt of CB] (CC) {};
\end{tikzpicture}};

\node[container] (mask_tp1_dec) at (mask_tp1_dec_ -| mask_tp1) {\begin{tikzpicture}
    \node[adjacency, fill=LimeGreen] (AA) {};
    \node[adjacency, fill=Magenta, right=1pt of AA] (AB) {};
    \node[adjacency, fill=LimeGreen, right=1pt of AB] (AC) {};
    
    \node[adjacency, fill=LimeGreen, below=1pt of AA] (BA) {};
    \node[adjacency, fill=LimeGreen, right=1pt of BA] (BB) {};
    \node[adjacency, fill=LimeGreen, right=1pt of BB] (BC) {};
    
    \node[adjacency, fill=Magenta, below=1pt of BA] (CA) {};
    \node[adjacency, fill=gray!20, right=1pt of CA] (CB) {};
    \node[adjacency, fill=LimeGreen, right=1pt of CB] (CC) {};
\end{tikzpicture}};
\coordinate (mid2) at ($(mask_tp1_dec_)!0.5!(mask_tp1_dec)$);
\draw[edge] (mask_tp1_dec) -- (mask_tp1);
\draw[edge] (mask_t) -- (mask_t_dec);
\draw[edge] (mask_tp1_dec_) -- (mask_tp1_dec);
\draw[rounded corners=2pt, edge] (mask_tp1_) -| (mid2) -- (mask_tp1_dec);

\node[] (graph_tp1) at (graph_t -| mask_tp1) {\begin{tikzpicture}
    \node[var] (A) {$A$};
    \node[var, above right=1em and 0.5em of A] (B) {$B$};
    \node[var, below right=1em and 0.5em of B] (C) {$C$};
    
    \draw[edge] (A) -- (B);
    \draw[edge] (C) -- (A);
\end{tikzpicture}};
\node[] (graph_tp1_label) at (graph_t_label -| graph_tp1) {$G_{t+1}$};
\draw[edge] (mask_t_) -- (mask_tp1_);
\node[] (mask_tp1_label) at (mask_t_label -| mask_tp1) {$\bm{m}_{t+1}$};

\node[] (update) at ($(mask_t_dec_2)!0.5!(mask_tp1_dec_)$) {\begin{tikzpicture}
    \node[] (v1) {\begin{tikzpicture}
        \node[mini adjacency, fill=NavyBlue] (AA) {};
        \node[mini adjacency, fill=NavyBlue, below=0.5pt of AA] (AB) {};
        \node[mini adjacency, fill=NavyBlue!20, below=0.5pt of AB] (AC) {};
    \end{tikzpicture}};
    \node[right=1pt of v1, font=\tiny] (odot) {$\otimes$};
    \node[right=1pt of odot] (v2) {\begin{tikzpicture}
        \node[mini adjacency, fill=Red!20] (AA) {};
        \node[mini adjacency, fill=Red!20, below=0.5pt of AA] (AB) {};
        \node[mini adjacency, fill=Red, below=0.5pt of AB] (AC) {};
    \end{tikzpicture}};
    \node[right=1pt of v2, font=\tiny] (equal) {$=$};
    \node[right=1pt of equal] (v3) {\begin{tikzpicture}
        \node[mini adjacency, fill=Purple!20] (AA) {};
        \node[mini adjacency, fill=Purple!20, below=0.5pt of AA] (AB) {};
        \node[mini adjacency, fill=Purple!20, below=0.5pt of AB] (AC) {};
        \node[mini adjacency, fill=Purple!20, right=0.5pt of AA] (BA) {};
        \node[mini adjacency, fill=Purple!20, below=0.5pt of BA] (BB) {};
        \node[mini adjacency, fill=Purple!20, below=0.5pt of BB] (BC) {};
        \node[mini adjacency, fill=Purple, right=0.5pt of BA] (CA) {};
        \node[mini adjacency, fill=Purple, below=0.5pt of CA] (CB) {};
        \node[mini adjacency, fill=Purple!20, below=0.5pt of CB] (CC) {};
    \end{tikzpicture}};
\end{tikzpicture}};

\draw[thick, shorten >=2pt] (mask_t_dec_2.east) -- (update.west);
\draw[edge, shorten <=2pt] (update.east) -- (mask_tp1_dec_.west);

\node[below=2pt of mask_t_, align=center, font=\scriptsize] (label_adj) {Adjacency\\matrix of $G_{t}$};
\node[below=2pt of mask_t_dec_1, align=center, font=\scriptsize] (label_closure) {Transitive\\closure of $G_{t}^{\top}$};

\end{tikzpicture}};

\end{tikzpicture}
\end{document}