% \begin{algorithm}[!ht]
%   \small
%   \KwInput{
%     \begin{itemize}[leftmargin=*]
%         \item Rating vectors of $M$ users $\{\textbf{y}^u\}_{u=1}^M$
%         \item Text vectors of $M$ users $\{\textbf{t}^u\}_{u=1}^M$
%         \item {Rating channel's parameters $\Theta^y$
%             \begin{itemize}
%                 \item item matrix in decoder $\textbf{H} \in \mathbb{R}^{N \times d}$
%                 % \item context matrix $\textbf{C}^y \in \mathbb{R}^{N \times D}$
%                 \item prototype representations $\textbf{m}^y \in \mathbb{R}^{K \times d}$
%                 \item MLP's parameters $\textbf{W}_1 \in \mathbb{R}^{N \times D}, \textbf{b}_1 \in \mathbb{R}^{D}, \textbf{W}_2 \in \mathbb{R}^{D \times 2d}, \textbf{b}_2 \in \mathbb{R}^{2d}$
%             \end{itemize}
%         }
%         \item {Text channel's parameters $\Theta^t$
%             \begin{itemize}
%                 \item decoder weight matrix $\textbf{E} \in \mathbb{R}^{W \times d}$
%                 % \item context matrix $\textbf{C}^t \in \mathbb{R}^{W \times D}$
%                 \item prototype representations $\textbf{m}^t \in \mathbb{R}^{J \times d}$
%                 \item MLP's parameters $\textbf{W}'_1 \in \mathbb{R}^{W \times D}, \textbf{b}'_1 \in \mathbb{R}^{D}, \textbf{W}'_2 \in \mathbb{R}^{D \times 2d}, \textbf{b}'_2 \in \mathbb{R}^{2d}$
%             \end{itemize}
%         }
%         \item Parameters of fusion layer $\zeta: \mathbb{R}^{2d} \rightarrow \mathbb{R}^1$ 
%         \item Hyper-parameters $\tau, \epsilon, \sigma^y, \sigma^t, L^y, L^t$
%     \end{itemize}
%     }
%   \KwOutput{
%     % \begin{itemize}[leftmargin=*]
%     %     \item Updated $\Theta^y$ and $\Theta^t$
%     % \end{itemize}
%     Updated $\Theta^y$ and $\Theta^t$
%     }

%     \For{each batch of user $\mathcal{B}$}{
%         \For{user $u \in \mathcal{B}$} {
%             $\{\textbf{z}^{uy}_k\}_{k=1}^K \leftarrow \bm{\mathcal{E}}^y (\textbf{y}^u, \textbf{m}^y, \textbf{H}, \tau, \sigma^y, L^y)$ \tcp{Rating encoder}
    
%             $\{\textbf{z}^{ut}_j\}_{j=1}^J \leftarrow  \bm{\mathcal{E}}^t (\textbf{t}^u, \textbf{m}^t, \textbf{E}, \tau, \sigma^t, L^t)$ \tcp{Text encoder}
    
%             $\pi^u \leftarrow \text{Sinkhorn\ algorithm} (\{\textbf{z}^{uy}_k\}_{k=1}^K, \{\textbf{z}^{ut}_j\}_{j=1}^J, \epsilon)$ \tcp{Alignment matrix in Algorithm \ref{alg:sinkhorn_alg}}
    
%             $\{\hat{\textbf{z}}^{uy}_k\}_{k=1}^K \leftarrow \text{Barycentric\ mapping}(\pi^u, \{\textbf{z}^{ut}_j\}_{j=1}^J)$ \tcp{Equation ~\ref{eqn:transport_rating}}
    
%             $\{\hat{\textbf{z}}^{ut}_j\}_{j=1}^J \leftarrow \text{Barycentric\ mapping}(\pi^u, \{\textbf{z}^{uy}_k\}_{k=1}^K)$ \tcp{Equation ~\ref{eqn:transport_text}}
    
%             $\tilde{\textbf{z}}^{uy} \leftarrow \text{Fuse}(\{\textbf{z}^{uy}_k\}_{k=1}^K, \{\hat{\textbf{z}}^{uy}_k\}_{k=1}^K)$  \tcp{Equation ~\ref{eqn:fuse_rating}}
    
%             $\tilde{\textbf{z}}^{ut} \leftarrow \text{Fuse}(\{\textbf{z}^{ut}_j\}_{j=1}^J, \{\hat{\textbf{z}}^{ut}_j\}_{j=1}^J)$  \tcp{Equation ~\ref{eqn:fuse_text}}
    
%             $\mathcal{L}^y_u \leftarrow \text{Calculate\ rating\ channel\ loss}$ \tcp{Equation \ref{eqn:rating_objective}}
    
%             $\mathcal{L}^t_u \leftarrow \text{Calculate\ text\ channel\ loss}$ \tcp{Equation \ref{eqn:text_objective}}
    
%             $\mathcal{L}^{OT}_u \leftarrow \text{Calculate regularization term}$ \tcp{Equation \ref{eqn:OT_reg}}
%         }
%         Calculate loss $\mathcal{L} = \frac{1}{||\mathcal{B}||}\sum_{u \in \mathcal{B}} \mathcal{L}^y_u + \lambda_t \cdot \mathcal{L}^t_u + \lambda_r \cdot \mathcal{L}^{OT}_u$ 
        
%         Update $\Theta^y, \Theta^t$ to minimize $\mathcal{L}$
%     }
    
%     \caption{Training procedure of \ourmethod}
%     \label{alg:pseudo_code}
% \end{algorithm}
\begin{algorithm}[!ht]
  \small
  \KwInput{
    \begin{itemize}[leftmargin=*]
        \item Rating and text vectors of $M$ users $\{\textbf{y}^u\}_{u=1}^M$ and $\{\textbf{t}^u\}_{u=1}^M$.
        \item {Rating channel's parameters $\Theta^y$: item matrix in decoder $\textbf{H} \in \mathbb{R}^{N \times d}$; prototype representations $\textbf{m}^y \in \mathbb{R}^{K \times d}$; MLP's parameters: $\textbf{W}_1 \in \mathbb{R}^{N \times D}, \textbf{b}_1 \in \mathbb{R}^{D}, \textbf{W}_2 \in \mathbb{R}^{D \times 2d}, \textbf{b}_2 \in \mathbb{R}^{2d}$
        }
        \item Text channel's parameters $\Theta^t$: decoder weight matrix $\textbf{E} \in \mathbb{R}^{W \times d}$; prototype representations $\textbf{m}^t \in \mathbb{R}^{J \times d}$; MLP's parameters: $\textbf{W}'_1 \in \mathbb{R}^{W \times D}, \textbf{b}'_1 \in \mathbb{R}^{D}, \textbf{W}'_2 \in \mathbb{R}^{D \times 2d}, \textbf{b}'_2 \in \mathbb{R}^{2d}$
        \item Parameters of fusion layer $\zeta: \mathbb{R}^{2d} \rightarrow \mathbb{R}^1$ 
        \item Hyper-parameters $\tau, \epsilon, \sigma^y, \sigma^t, L^y, L^t$
    \end{itemize}
    }
  \KwOutput{
    % \begin{itemize}[leftmargin=*]
    %     \item Updated $\Theta^y$ and $\Theta^t$
    % \end{itemize}
    Updated $\Theta^y$ and $\Theta^t$
    }

    \For{each batch of user $\mathcal{B}$}{
        \For{user $u \in \mathcal{B}$} {
            $\{\textbf{z}^{uy}_k\}_{k=1}^K \leftarrow \bm{\mathcal{E}}^y (\textbf{y}^u, \textbf{m}^y, \textbf{H}, \tau, \sigma^y, L^y)$ \tcp{Rating encoder}
    
            $\{\textbf{z}^{ut}_j\}_{j=1}^J \leftarrow  \bm{\mathcal{E}}^t (\textbf{t}^u, \textbf{m}^t, \textbf{E}, \tau, \sigma^t, L^t)$ \tcp{Text encoder}
    
            $\pi^u \leftarrow \text{Sinkhorn\ algorithm} (\{\textbf{z}^{uy}_k\}_{k=1}^K, \{\textbf{z}^{ut}_j\}_{j=1}^J, \epsilon)$ \tcp{Alignment matrix in Algorithm \ref{alg:sinkhorn_alg}}
    
            $\{\hat{\textbf{z}}^{uy}_k\}_{k=1}^K \leftarrow \text{Barycentric\ mapping}(\pi^u, \{\textbf{z}^{ut}_j\}_{j=1}^J)$ \tcp{Equation ~\ref{eqn:transport_rating}}
    
            $\{\hat{\textbf{z}}^{ut}_j\}_{j=1}^J \leftarrow \text{Barycentric\ mapping}(\pi^u, \{\textbf{z}^{uy}_k\}_{k=1}^K)$ \tcp{Equation ~\ref{eqn:transport_text}}
    
            $\tilde{\textbf{z}}^{uy} \leftarrow \text{Fuse}(\{\textbf{z}^{uy}_k\}_{k=1}^K, \{\hat{\textbf{z}}^{uy}_k\}_{k=1}^K)$  \tcp{Equation ~\ref{eqn:fuse_rating}}
    
            $\tilde{\textbf{z}}^{ut} \leftarrow \text{Fuse}(\{\textbf{z}^{ut}_j\}_{j=1}^J, \{\hat{\textbf{z}}^{ut}_j\}_{j=1}^J)$  \tcp{Equation ~\ref{eqn:fuse_text}}
    
            $\mathcal{L}^y_u \leftarrow \text{Rating\ channel\ loss}$ \tcp{Equation \ref{eqn:rating_objective}}
    
            $\mathcal{L}^t_u \leftarrow \text{Text\ channel\ loss}$ \tcp{Equation \ref{eqn:text_objective}}
    
            $\mathcal{L}^{OT}_u \leftarrow \text{Regularization term}$ \tcp{Equation \ref{eqn:OT_reg}}
        }
        Calculate loss $\mathcal{L} = \frac{1}{||\mathcal{B}||}\sum_{u \in \mathcal{B}} \mathcal{L}^y_u + \lambda_t \cdot \mathcal{L}^t_u + \lambda_r \cdot \mathcal{L}^{OT}_u$ 
        
        Update $\Theta^y, \Theta^t$ to minimize $\mathcal{L}$
    }
    
    \caption{Training procedure of \ourmethod}
    \label{alg:pseudo_code}
\end{algorithm}
