SlowGuess/NeurIPS_2023_OCR huggingface dataset:
where  $\delta_v$  is the optimal spatio-temporal invariance threshold of node  $v$ .
Proposition 2 solves a dynamic programming problem to obtain the optimal  $\mathbb{I}^{\star}(\cdot)$ , whose target is to find a partition dividing all patterns into variant/invariant set with the maximum difference between the variance means that reveals the current invariance status, providing an ideal optimizing start point. The proof can be found in Appendix C.2.
With the theoretical support of Assumption 1 and Proposition 2, we can recognize the spatio-temporal invariant/variant patterns  $\mathcal{P}_{\mathbf{e}}^{I} = \bigcup_{v\in \mathcal{V}}\mathcal{P}_{\mathbf{e}}^{I}(v)$  and  $\mathcal{P}_{\mathbf{e}}^{V} = \bigcup_{v\in \mathcal{V}}\mathcal{P}_{\mathbf{e}}^{V}(v)$  with respect to the underlying environments for each node over a period of time by applying  $\mathbb{I}(\cdot)$ .
3.4 Environments Generalizing with Causal Intervention
Generalization Optimization Objective. Eq. (2) clarifies the training objective of OOD generalization. However, directly optimizing Eq. (2) is not impracticable. Based on the inferred and generated environments in Section 3.2 and spatio-temporal invariant patterns learned in Section 3.3, we further modify Eq. (2) to improve the model's OOD generalization ability by applying the intervention mechanism node-wisely with causal inference. Specifically, we have the following objectives:
$$
\min  _ {\theta} \mathcal {L} _ {\text {t a s k}} + \alpha \mathcal {L} _ {\text {r i s k}}, \tag {12}
$$
$$
\mathcal {L} _ {\text {t a s k}} = \mathbb {E} _ {\mathbf {e} \sim q _ {\phi} (\mathbf {e}), (\mathcal {G} ^ {1: T}, Y ^ {T}) \sim p \left(\mathbf {G} ^ {1: T}, \mathbf {Y} ^ {T} \mid \mathbf {e}\right)} \left[ \ell \left(g \left(\mathbf {Z} _ {I} ^ {1: T}\right), Y ^ {T}\right) \right], \tag {13}
$$
$$
\mathcal {L} _ {\text {r i s k}} = \operatorname {V a r} _ {s \in \mathcal {S}} \left\{\mathbb {E} _ {\mathbf {e} \sim q _ {\phi} (\mathbf {e}), \left(\mathcal {G} ^ {1: T}, Y ^ {T}\right) \sim p \left(\mathbf {G} ^ {1: T}, \mathbf {Y} ^ {T} \mid \mathbf {e}\right)} \left[ \ell \left(f _ {\boldsymbol {\theta}} \left(\mathcal {G} ^ {1: T}\right), Y ^ {T} \mid \mathrm {d o} \left(\mathbf {Z} _ {V} ^ {1: T} = s\right)\right) \right] \right\}, \tag {14}
$$
where  $q_{\phi}(\mathbf{e})$  is the environment distribution in Section 3.2,  $\mathrm{do}(\cdot)$  is the do-calculus that intervenes the variant patterns,  $S = S_{\mathrm{ob}} \cup S_{\mathrm{ge}}$  is the observed and generated environment instances for interventions, and  $\alpha$  is a hyperparameter. We show the optimality of Eq. (12) with the following propositions:
Proposition 3 (Achievable Assumption). Minimizing Eq. (12) can encourage the model to satisfy the Invariance Property and Sufficient Condition in Assumption 1.
Proposition 4 (Equivalent Optimization). Optimizing Eq. (12) is equivalent to minimizing the upper bound of the OOD generalization error in Eq. (2).
Proposition 3 avoids over-strong assumptions of the Sufficient Condition and Invariance Property. Proposition 4 guarantees the OOD generalization error bound of the learned model is within our expectation, which can also be explained in the perspective of the SCM model on dynamic graphs (Figure 1(b)) that, optimizing Eq. (12) eliminates the negative impacts brought by spatio-temporal spurious correlations between labels and variant patterns, while strengthening the invariant causal correlations under diverse latent environments. Proofs for Proposition 3 and Proposition 4 can be found in Appendix C.3 and C.4, respectively.
Spatio-temporal Causal Intervention Mechanism. As directly intervening the variant patterns node-wisely is time-consuming and intractable, we propose to approximately perform fine-grained spatio-temporal interventions with  $S_{\mathrm{ob}} \cup S_{\mathrm{ge}}$  by sampling and replacing variant patterns. For environment-aware representations  $\mathbf{z}_v^{et} = [\mathbf{z}_{v,1}^t, \mathbf{z}_{v,2}^t, \dots, \mathbf{z}_{v,K}^t]$  of node  $v$  at time  $t$ , we can obtain  $\mathcal{P}_{\mathbf{e}}^{I}(v)$  and  $\mathcal{P}_{\mathbf{e}}^{V}(v)$  by applying  $\mathbb{I}(\cdot)$ . As  $\mathcal{P}_{\mathbf{e}}^{V}(v)$  represents environment indices related to variant patterns, we randomly sample instances as the intervention set  $\mathbf{s}_v$  and perform node-wise replacing:
$$
\mathbf {z} _ {v} ^ {\mathrm {e}, t} \left[ \mathcal {P} _ {\mathrm {e}} ^ {V} (v) \right] := \mathbf {s} _ {v}, \quad \mathbf {s} _ {v} = \{s \mid s \in \mathcal {S} _ {\mathrm {o b}} \cup \mathcal {S} _ {\mathrm {g e}} \}. \tag {15}
$$
Note that, for each intervention operation, we randomly perform each replacement with a different  $s$ . Further considering ECVAE loss in Eq. (8), the overall loss of EAGLE is defined as:
$$
\mathcal {L} = \left. \mathcal {L} _ {\text {t a s k}} + \alpha \right. \left. \mathcal {L} _ {\text {r i s k}} + \beta \right. \left. \mathcal {L} _ {\text {E C V A E}} \right., \tag {16}
$$
$$
\begin{array}{c c c} \text {E q . (1 3)} & \text {E q . (1 4)} & \text {E q . (8)} \end{array}
$$
where  $\beta$  is another hyperparameter. We conduct hyperparameter sensitivity analysis in Appendix D.4. The training process of EAGLE is summarized in Appendix B.
Datasets. We use three real-world datasets to evaluate EAGLE<sup>1</sup> on the challenging link prediction task. COLLAB [81] is an academic collaboration dataset with papers published in 16 years; Yelp [75] contains customer reviews on business for 24 months; ACT [45] describes students actions on a MOOC platform within 30 days. Statistics of the three datasets are concluded in Table D.1.
Baselines. We compare EAGLE with representative GNNs and OOD generalization methods.
- Static GNNs: GAE [42] and VGAE [42] are GCN [41] based autoencoders on static graphs.
- Dynamic GNNs: GCRN [76] adopts GCNs to obtain node embeddings, followed by a GRU [13] to capture temporal relations; EvolveGCN [62] applies an LSTM [31] or GRU to evolve the parameters of GCNs; DySAT [75] models self-attention in both structural and temporal domains.
- OOD Generalization Methods: IRM [3] learns an invariant predictor to minimize invariant risk; V-REx [44] extends IRM by reweighting the risk; GroupDRO [74] reduces the risk gap across training distributions; DIDA [94] exploits invariant patterns on dynamic graphs.
4.1 Evaluation of Performance on Future Link Prediction Task
4.1.1 Distribution Shifts on Link Attributes
Settings. Each dataset owns multi-attribute relations. We filter out one certain attribute links as the shifted variables under the future OOD environments in validation and training sets chronologically. This is more practical and challenging in real-world scenarios as the model cannot get access to any information about the filtered links until testing stages. Note that, all attribute features have been removed after the above operations before feeding to EAGLE. Detailed settings are in Appendix D.3.
Results. Results are shown in Table 1. w/o OOD and w/ OOD denote testing without and with distribution shifts. The performance of all baselines drops dramatically on each dataset when there exist distribution shifts. Static GNN baselines fail in both settings as they cannot model dynamics.
$^{1}$ Code is available at https://github.com/RingBDStack/EAGLE on PyTorch [63] and MindSpore [33].
Though dynamic GNNs are designed to capture spatio-temporal features, they even underperform static GNNs in several settings, mainly because the predictive patterns they exploited are variant with spurious correlations. Conventional OOD generalization baselines have limited improvements as they rely on the environment labels to generalize, which are inaccessible on dynamic graphs. As the most related work, DIDA [94] achieves further progress by learning invariant patterns. However, it is limited by the lack of in-depth analysis into the environments, causing the label shift phenomenon [91] that damages its generalization ability. With the critical investigation of latent environments and theoretical guarantees, our EAGLE consistently outperforms the baselines and achieves the best performance in all  $w/ OOD$  settings and two  $w/o OOD$  settings. Especially even on the most challenging COLLAB, where the time span is extremely long (1990 to 2006) and its link attributes difference is huge.
Table 1: AUC score (\% ± standard deviation) of future link prediction task on real-world datasets with OOD shifts of link attributes. The best results are shown in bold and the runner-ups are underlined.
Dataset	COLLAB	Yelp	ACT
Model	w/o OOD	w/ OOD	w/o OOD	w/ OOD	w/o OOD	w/ OOD
GAE [42]	77.15±0.50	74.04±0.75	70.67±1.11	64.45±5.02	72.31±0.53	60.27±0.41
VGAE [42]	86.47±0.04	74.95±1.25	76.54±0.50	65.33±1.43	79.18±0.47	66.29±1.33
GCRN [76]	82.78±0.54	69.72±0.45	68.59±1.05	54.68±7.59	76.28±0.51	64.35±1.24
EvolveGCN [62]	86.62±0.95	76.15±0.91	78.21±0.03	53.82±2.06	74.55±0.33	63.17±1.05
DySAT [75]	88.77±0.23	76.59±0.20	78.87±0.57	66.09±1.42	78.52±0.40	66.55±1.21
IRM [3]	87.96±0.90	75.42±0.87	66.49±10.78	56.02±16.08	80.02±0.57	69.19±1.35
V-REx [44]	88.31±0.32	76.24±0.77	79.04±0.16	66.41±1.87	83.11±0.29	70.15±1.09
GroupDRO [74]	88.76±0.12	76.33±0.29	79.38±0.42	66.97±0.61	85.19±0.53	74.35±1.62
DIDA [94]	91.97±0.05	81.87±0.40	78.22±0.40	75.92±0.90	89.84±0.82	78.64±0.97
EAGLE	92.45±0.21	84.41±0.87	78.97±0.31	77.26±0.74	92.37±0.53	82.70±0.72
4.1.2 Distribution Shifts of Node Features
Setting. We further introduce settings of node feature shifts on COLLAB. We respectively sample  $p(t)|\mathcal{E}^{t + 1}|$  positive links and  $(1 - p(t))|\mathcal{E}^{t + 1}|$  negative links, which are then factorized into shifted features  $\mathbf{X}^{t'} \in \mathbb{R}^{|V| \times d}$  while preserving structural property. The sampling probability  $p(t) = \bar{p} + \sigma \cos(t)$ , where  $\mathbf{X}^{t'}$  with higher  $p(t)$  will have stronger spurious correlations with future underlying environments. We set  $\bar{p}$  to be 0.4, 0.6 and 0.8 for training and 0.1 for testing. In this way, training data are relatively higher spuriously correlated than the testing data. We omit results on static GNNs as they cannot support dynamic node features. Detailed settings are in Appendix D.3.
Results. Results are reported in Table 2. We can observe a similar trend as Table 1, i.e., our method better handles distribution shifts of node features on dynamic graphs than the baselines. Though some baselines can report reasonably high performance on the training set, their performance drops drastically in the testing stage. In comparison, our method reports considerably smaller gaps. In particular, our EAGLE surpasses the best-performed baseline by approximately  $3\% /5\% /10\%$  of AUC in the testing set under different shifting levels. Interestingly, as severer distribution shifts will lead to more significant performance degradation where the spurious correlations are strengthened, our method gains better task performance with a higher shifting degree. This demonstrates EAGLE is more capable of eliminating spatio-temporal spurious correlations in severer OOD environments.
4.2 Investigation on Invariant Pattern Recognition Mechanism
Settings. We generate synthetic datasets by manipulating environments to investigate the effect of the invariant pattern recognition mechanism. We set  $K = 5$  and let  $\sigma_{\mathrm{e}}$  represent the proportion of the environments in which the invariant patterns are learned, where higher  $\sigma_{\mathrm{e}}$  means more reliable invariant patterns. Node features are drawn from multivariate normal distributions, and features under the invariant patterns related  $\mathbf{e}_k$  will be perturbed slightly and vice versa. We construct graph structures and filter out links built under a certain  $\mathbf{e}_k$  as the same in Section 4.1.1. We compare EAGLE with the most related and strongest baseline DIDA [94]. Detailed settings are in Appendix D.3.
Results. Results are shown in Figure 3.  $\mathbb{I}_{\mathrm{ACC}}$  denotes the prediction accuracy of the invariant patterns by  $\mathbb{I}(\cdot)$ . We observe that, as  $\sigma_{\mathrm{e}}$  increases, the performance of EAGLE shows a significant increase from  $54.26\%$  to  $65.09\%$  while narrowing the gap between w/o OOD and w/ OOD scenarios.
Table 2: AUC score (\% ± standard deviation) of future link prediction task on real-world datasets with OOD shifts of node features. The best results are shown in bold and the runner-ups are underlined.
Dataset	COLLAB (p̅ = 0.4)	COLLAB (p̅ = 0.6)	COLLAB (p̅ = 0.8)
Model	Train	Test	Train	Test	Train	Test
GCRN [76]	69.60±1.14	72.57±0.72	74.71±0.17	72.29±0.47	75.69±0.07	67.26±0.22
EvolveGCN [62]	78.82±1.40	69.00±0.53	79.47±1.68	62.70±1.14	81.07±4.10	60.13±0.89
DySAT [75]	84.71±0.80	70.24±1.26	89.77±0.32	64.01±0.19	94.02±1.29	62.19±0.39
IRM [3]	85.20±0.07	69.40±0.09	89.48±0.22	63.97±0.37	95.02±0.09	62.66±0.33
V-REx [44]	84.77±0.84	70.44±1.08	89.81±0.21	63.99±0.21	94.06±1.30	62.21±0.40
GroupDRO [74]	84.78±0.85	70.30±1.23	89.90±0.11	64.05±0.21	94.08±1.33	62.13±0.35
DIDA [94]	87.92±0.92	85.20±0.84	91.22±0.59	82.89±0.23	92.72±2.16	72.59±3.31
EAGLE	92.97±0.88	88.32±0.61	94.52±0.42	87.29±0.71	94.11±1.03	82.30±0.75
Though DIDA [94] also shows an upward trend, its growth rate is more gradual. This indicates that, as DIDA [94] is incapable of modeling the environments, it is difficult to perceive changes in the underlying environments caused by different  $\sigma_{\mathbf{e}}$ , thus cannot achieve satisfying generalization performance. In comparison, our EAGLE can exploit more reliable invariant patterns, thus performing high-quality invariant learning and efficient causal interventions, and achieving better generalization ability. In addition, we also observe a positive correlation between  $\mathbb{I}_{\mathrm{ACC}}$  and the AUC, indicating the improvements is attributed to the accurate recognition of the invariant patterns by  $\mathbb{I}(\cdot)$ . Additional results are in Appendix D.7.
In this section, we conduct ablation studies to analyze the effectiveness of three main mechanisms:
- EAGLE (w/o EI). We remove the Environment Instantiation mechanism in Section 3.2, and carrying out causal interventions in Eq. (15) with only observed environment samples.
- EAGLE (w/o IPR). We remove the Invariant Pattern Recognition mechanism in Section 3.3, and determining the spatio-temporal invariant patterns  $\mathcal{P}_{\mathrm{e}}^{I}$  by randomly generating  $\delta_v$  for each node.
- EAGLE (w/o Interv). We remove the spatio-temporal causal Intervention mechanism in Section 3.4 and directly optimize the model by Eq. (16) without the second  $\mathcal{L}_{\mathrm{risk}}$  term.
Results. Results are demonstrated in Figure 4. Overall, EAGLE consistently outperforms the other three variants on all datasets. The ablation studies provide insights into the effectiveness of the proposed mechanisms and demonstrate their importance in achieving better performance for OOD generalization on dynamic graphs.
Figure 3: Effects of invariant pattern recognition.
Figure 4: Results of ablation study.
We visualize snapshots in COLLAB using NetworkX [27] as shown in Figure 5, where colors reflect latent environments, numbers denote edge weights, solid lines implicate spatio-temporal invariant patterns dependencies, and dashed lines implicate variant patterns dependencies. EAGLE can gradually exploit the optimal invariant patterns and strengthen reliance, making generalized predictions.
Figure 5: Visualization of snapshots in COLLAB.
Dynamic Graph Learning. Extensive researches [70, 4, 38, 90, 85, 35] address the challenges of dynamic graph learning. Dynamic graph neural networks (DGNNs) are intrinsically utilized to model both spatial and temporal patterns [88, 76, 84, 73, 62, 75, 80, 21] by combining vanilla GNNs and sequential-based models [58, 31, 28]. However, most existing works fail to generalize under distribution shifts. DIDA [94] is the sole prior work that tackles distribution shifts on dynamic graphs, but it neglects to model the complex environments, which is crucial in identifying invariant patterns.
Out-of-Distribution Generalization. Most machine learning methods are built on the I.I.D. hypothesis, which can hardly be satisfied in real-world scenarios [77, 71, 3]. Out-of-distribution (OOD) generalization has been extensively studied in both academia and industry areas [77, 92, 30] and we mainly focus on graphs. Most works concentrate on static graphs for node-level or graph-level tasks [98, 18, 49, 86, 52, 12, 87], supporting by invariant learning method [14, 46, 95] with disentangled learning [5, 55] and causal inference theories [65, 66, 64]. However, there lack of further research on dynamic graphs with more complicated shift patterns caused by spatio-temporal varying latent environments, which is our main concern.
Invariant Learning. Invariant learning aims to exploit the fewer variant patterns that lead to informative and discriminative representations for stable prediction [14, 46, 95]. Supporting by disentangled learning theories and causal learning theories, invariant learning tackles the OOD generalization problem from a more theoretical perspective, revealing a promising power. Disentangle-based methods [5, 55] learn representations by separating semantic factors of variations in data, making it easier to distinguish invariant factors and establish reliable correlations. Causal-based methods [22, 3, 72, 87, 11, 2, 60] utilize Structural Causal Model (SCM) [64] to filter out spurious correlations by intervention or counterfactual with  $do$ -calculus [65, 66] and strengthen the invariant causal patterns. However, the invariant learning method of node-level tasks on dynamic graphs is underexplored, mainly due to its complexity in analyzing both spatial and temporal invariant patterns.
In this paper, we propose a novel framework EAGLE for out-of-distribution (OOD) generalization on dynamic graphs by modeling complex dynamic environments for the first time and further exploiting spatio-temporal invariant patterns. EAGLE first models environment by an environment-aware DGNN, and then diversifies the observed environment samples with the environment instantiation mechanism, and finally learns OOD generalized spatio-temporal invariant patterns by the invariant pattern recognition mechanism and performs fine-grained causal interventions node-wisely. Experiment results on both real-world and synthetic datasets demonstrate that EAGLE greatly outperforms existing methods under distribution shifts. One limitation is that we mainly consider the node-level tasks, and leave extending our method to the graph-level OOD generalization for future explorations.
The corresponding author is Qingyun Sun. The authors of this paper are supported by the National Natural Science Foundation of China through grants No.62225202, No.62302023, and No.62206149. We owe sincere thanks to all authors for their valuable efforts and contributions. We also acknowledge the support of MindSpore, CANN (Compute Architecture for Neural Networks) and Ascend AI Processor used for this research.
Notations	Descriptions
DG = {G}Tt=1	Dynamic graph (a set of T discrete graph snapshots)
G = (V, E)	Graph with the node set V and edge set E
Gt = (Vt, Et)	Graph snapshot at time t
Xt, At	Node features matrix and adjacency matrix of a graph at time t
xtv, A(t(u,v),k)	Node features and edge weights of (u,v) under ek
G1:t, Yt, G1:t, Yt	Graph trajectory, labels and their corresponding random variables
e, ei, E	Latent environments and their support
ztv,k, ztev, zve	Node representations under ek, at time t and at overall time slices
z, y	Observed environment sample with its label
d, d'	Dimension for xt and ztk, respectively
K	Number of underlying environments (number of convolution channel)
f(·), w(·), g(·)	Model, encoder, and the link predictor
l(·)	The loss function
qφ, pω	The prior distribution and variational distribution of environments
I* (·), I(·)	Invariant pattern recognition function and its implementation
PEI, PEV, PEI(v), PEV(v)	Summary of spatio-temporal invariant/variant patterns for each node
Z1:t, Z1:t, Z1:t	Summary of node representations, and their variants under PEI and PV
Sob, Sge	Observed and generated environments sample libraries
s, Sv	Intervention samples from Sob ∪ Sge and their summary for node v
do(·)	do-caculus for causal interventions
Ltask, Lrisk, LECVAE	Task loss, the invariance loss and the ECVAE loss
α, β	Hyperparameters for loss trade-off
B Algorithm and Complexity Analysis
Algorithm 1: Overall training process of EAGLE.
Input: Dynamic graph  $\mathbf{DG} = (\{\mathcal{G}\}_{t=1}^{T})$  with labels  $\mathbf{Y}^{1:T}$  of link occurrence; Number of training epochs  $E$ ; Number of intervention times  $S$ ; Hyperparameters  $\alpha$  and  $\beta$ . Output: Optimized model  $f_{\theta}^{\star}$ ; Predicted label  $Y^{T}$  of link occurrence at time  $T + 1$ .  
1 Initialize parameters randomly;  
2 for  $i = 1,2,\dots ,E$  do  
3 // Environments Modeling and Inferring  
4 Obtain representations for each node at each time with the support of  $\mathbf{e}$ , as  $\mathbf{z}_v^{\mathrm{e},t} \gets \mathrm{Eq. (6)}$ ;  
5 Establish the observed environment samples library  $S_{\mathrm{ob}} \gets \mathrm{Eq. (7)}$ ;  
6 Infer the distribution  $p_{\omega}(\mathbf{e})$  with  $\mathcal{L}_{\mathrm{ECVAE}} \gets \mathrm{Eq. (8)}$  and generate samples library  $S_{\mathrm{ge}}$ ;  
7 // Environments Extrapolating  
8 Learn the invariance threshold  $\delta_v \gets \mathrm{Eq. (10)}$  by function  $\mathbb{I}(\cdot) \gets \mathrm{Eq. (9)}$ ;  
9 Recognize the invariant/variant patterns for each node, as  $\mathcal{P}_{\mathrm{e}}^{I}(v), \mathcal{P}_{\mathrm{e}}^{V}(v) \gets \mathrm{Eq. (11)}$ ;  
10 Calculate task loss depending on the invariant patterns, as  $\mathcal{L}_{\mathrm{task}} \gets \mathrm{Eq. (13)}$ ;  
11 // Environments Generalizing  
12 for  $j = 1,2,\dots ,S$  do  
13 Sample items from  $S_{\mathrm{ob}} \cup S_{\mathrm{ge}}$  and perform intervention for each node, as Eq. (15);  
14 Calculate intervention loss, as  $\mathcal{L}_{\mathrm{risk}} \gets \mathrm{Eq. (14)}$ ;  
15 end  
16 // Optimize  
17 Calculate the overall loss, as  $\mathcal{L} \gets \mathrm{Eq. (16)}$ ;  
18 Update model parameters by minimizing  $\mathcal{L}$ .  
19 end
The overall training process of our EAGLE is shown in Algorithm 1.
Computational Complexity Analysis. We analyze the computational complexity of each part in EAGLE as follows. Denote  $|\mathcal{V}|$  and  $|\mathcal{E}|$  as the total number of nodes and edges in each graph snapshot.
In Section 3.1, operations of the EACnv layer in EA-DGNN can be parallelized across all nodes, which is highly efficient. Thus, the computation complexity of EA-DGNN is:
$$
\mathcal {O} \left(| \mathcal {E} | \sum_ {l = 0} ^ {L} d ^ {(l)} + \mathcal {V} \left(\sum_ {l = 1} ^ {L} d ^ {(l - 1)} d ^ {(l)} + (d ^ {(L)}) ^ {2}\right)\right), \tag {B.1}
$$
where  $d^{(l)}$  denotes the dimension of the  $l$ -th layer. As  $L$  is a small number, and  $d^{(l)}$  is a constant, the Eq. (B.1) can be rewritten as  $\mathcal{O}(|\mathcal{E}|d + |\mathcal{V}|d^2)$ , where  $d$  is the universal notation of all  $d^{(l)}$ .
In Section 3.2, the computation complexity of the ECVAE is a compound of the encoder and decoder, with the same computation complexity as  $\mathcal{O}(|\mathbf{z}|L^{\prime}d)$ , where  $|\mathbf{z}|$  is the number of the observed environment samples,  $L^{\prime}$  is the number of layers in the encoder and decoder. Also, as  $L^{\prime}$  is a small number, we omit it for brevity. Thus, the computation complexity of ECVAE is  $\mathcal{O}(|\mathbf{z}|d)$ .
In Section 3.3, we recognize the invariant/variant patterns for all nodes by the function  $\mathbb{I}(\cdot)$  in parallel, with the computation complexity  $\mathcal{O}(K\log |\mathcal{V}|)$ .