\begin{algorithm2e}
\caption{\acl{SRA} pseudo code}
\label{alg:sra}
\SetAlgoLined
Initialize queue $\mathcal{Q}$ with normal distribution\;
Normalize queue entries $q_i \in Q$\;
\For{$\mathrm{epoch} = 0$ \KwTo $N_\mathrm{epochs}-1$}{
    Create $\mathcal{D}$ by uniformly sampling from $\mathcal{D}_s$ and $\mathcal{D}_t$\;
    Update easy-to-hard coefficient $r$ using \equationref{eq:r}\;
    \For{$\mathrm{batch}$ $\{x_i\}_{i=1}^B$ $\mathrm{in}$ $\mathcal{D}$}{
        Get augmented samples $\hat{x}, \hat{x}^{\prime}$ from $\mathcal{T}_x$ \;
        Perform forward pass $z=f_{\phi}(\hat{x}),\ z^\prime= f_{\psi}(\hat{x}^\prime)$ \;
        Normalize vectors $z, z^{\prime}$ \;
        Compute in-domain loss $\mathcal{L}_{\mathrm{IND}}$ using \equationref{eq:l_ind}\;
        Calculate cross-domain matching $H^{\mathrm{CRD}}$ using \equationref{eq:h_crd} \;
        Determine easy-to-hard samples set $\mathcal{R}_{s/t}$ using \equationref{eq:r} \;
        Compute cross-domain loss $\mathcal{L}_{\mathrm{CRD}}$ by replacing  $\mathcal{D}_{s/t}$ with $\mathcal{R}_{s/t}$ in \equationref{eq:l_crd}\;
        Compute $\mathcal{L}_{\mathrm{SRA}} = \mathcal{L}_{\mathrm{IND}} + \mathcal{L}_{\mathrm{CRD}}$\;
        Update $\Phi$ weights with backpropagation \;
        Update $\Psi$ weights with momentum using \equationref{eq:momentum_update}\;
        Update queue $\mathcal{Q}$ by appending $z^{\prime}$\;
    }
}
\end{algorithm2e}
