| 297 | return x |
| 298 | |
| 299 | class OneShotDataset(Dataset): |
| 300 | def __init__(self, original_dataset): |
| 301 | self.data = [] |
| 302 | self.labels = [] |
| 303 | class_samples = {} |
| 304 | |
| 305 | for i in range(len(original_dataset)): |
| 306 | data = original_dataset.data.x[i] |
| 307 | label = original_dataset.data.y[i].item() |
| 308 | if label not in class_samples: |
| 309 | class_samples[label] = data |
| 310 | self.labels.append(label) |
| 311 | |
| 312 | self.data = list(class_samples.values()) |
| 313 | |
| 314 | def __len__(self): |
| 315 | return len(self.data) |
| 316 | |
| 317 | def __getitem__(self, idx): |
| 318 | return self.data[idx], self.labels[idx] |
| 319 | |
| 320 | class AlignDataset(Dataset): |
| 321 | def __init__(self, features, label_emb, label): |
nothing calls this directly
no outgoing calls
no test coverage detected