Repository: pyg-team/pytorch_geometric

Issue:
CycleMotif lack of label, therefore do not support GNNExplainer.
### 🐛 Describe the bug

when running ./examples/explain/gnn_explainer_ba_shapes.py, when I replace the dataset:
```
dataset = ExplainerDataset(
    graph_generator=BAGraph(num_nodes=300, num_edges=5),
    motif_generator='house',
    num_motifs=80,
    transform=T.Constant(),
) 
```
with
```
dataset = ExplainerDataset(
    graph_generator=BAGraph(num_nodes=300, num_edges=5),
    motif_generator=CycleMotif(num_nodes=6), 
    num_motifs=80,
    transform=T.Constant(),
)
```
There is an error:
```
Traceback (most recent call last):
  File "/home/stt/py_github_repo_read/pytorch_geometric/examples/explain/gnn_explainer_ba_shapes.py", line 46, in <module>
    out_channels=dataset.num_classes).to(device)
  File "/home/stt/py_github_repo_read/pytorch_geometric/torch_geometric/data/in_memory_dataset.py", line 90, in num_classes
    return super().num_classes
  File "/home/stt/py_github_repo_read/pytorch_geometric/torch_geometric/data/dataset.py", line 173, in num_classes
    y = torch.cat([data.y for data in data_list if 'y' in data], dim=0)
RuntimeError: torch.cat(): expected a non-empty list of Tensors
```
The reason behind locate at line 23 in `./torch_geometric/datasets/motif_generator/cycle.py`
```
structure = Data(
            num_nodes=num_nodes,
            edge_index=torch.stack([row, col], dim=0),
# TODO: lack of y label
        )
```
lack of y label as in `./torch_geometric/datasets/motif_generator/house.py`
```
structure = Data(
            num_nodes=5,
            edge_index=torch.tensor([
                [0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4],
                [1, 3, 4, 4, 2, 0, 1, 3, 2, 0, 0, 1],
            ]),
            y=torch.tensor([0, 0, 1, 1, 2]),
        )
```
According to GNNExplainer original repository, for the cycle motif, the node labels are the same. Therefore, we only need to add `y=torch.tensor([0]*num_nodes)`

### Versions

PyTorch version: 2.1.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:49:32)  [GCC 12.3.0] (64-bit runtime)
Python platform: Linux-6.2.0-34-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090

Nvidia driver version: 535.113.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
架构：                              x86_64
CPU 运行模式：                      32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
字节序：                            Little Endian
CPU:                                24
在线 CPU 列表：                     0-23
厂商 ID：                           GenuineIntel
型号名称：                          13th Gen Intel(R) Core(TM) i7-13700KF
CPU 系列：                          6
型号：                              183
每个核的线程数：                    2
每个座的核数：                      16
座：                                1
步进：                              1
CPU 最大 MHz：                      5400.0000
CPU 最小 MHz：                      800.0000
BogoMIPS：                          6835.20
标记：                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
虚拟化：                            VT-x
L1d 缓存：                          640 KiB (16 instances)
L1i 缓存：                          768 KiB (16 instances)
L2 缓存：                           24 MiB (10 instances)
L3 缓存：                           30 MiB (1 instance)
NUMA 节点：                         1
NUMA 节点0 CPU：                    0-23
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.0
[pip3] torch==2.1.0
[pip3] torchvision==0.16.0
[pip3] triton==2.1.0
[conda] numpy                     1.26.0                   pypi_0    pypi
[conda] torch                     2.1.0                    pypi_0    pypi
[conda] torchvision               0.16.0                   pypi_0    pypi
[conda] triton                    2.1.0                    pypi_0    pypi


Discussion:
Additionally, the **grid motif** in GNNExplainer is absent from PYG. I'm interested in contributing to this project, especially as a beginner. If possible, this "good first issue" seems fitting for me, and it aligns with requirement for one of my course being studied.

Resolving patch:
diff --git a/torch_geometric/datasets/explainer_dataset.py b/torch_geometric/datasets/explainer_dataset.py
--- a/torch_geometric/datasets/explainer_dataset.py
+++ b/torch_geometric/datasets/explainer_dataset.py
@@ -119,12 +119,14 @@ def get_graph(self) -> Explanation:
 
             if 'y' in motif:
                 ys.append(motif.y + 1 if motif.y.min() == 0 else motif.y)
+            else:
+                ys.append(torch.ones(motif.num_nodes, dtype=torch.long))
 
             num_nodes += motif.num_nodes
 
         return Explanation(
             edge_index=torch.cat(edge_indices, dim=1),
-            y=torch.cat(ys, dim=0) if len(ys) > 1 else None,
+            y=torch.cat(ys, dim=0),
             edge_mask=torch.cat(edge_masks, dim=0),
             node_mask=torch.cat(node_masks, dim=0),
         )


Test patch: