| 236 | class AdaptiveMaskFactory: |
| 237 | @staticmethod |
| 238 | def create(config: MaskConfig, device: Optional[torch.device]) -> AdaptiveMaskBase: |
| 239 | if not config.enabled or config.strategy is None: |
| 240 | return NullAdaptiveMask() |
| 241 | if config.strategy == "learnable": |
| 242 | if device is None: |
| 243 | device = torch.device("cuda" if torch.cuda.is_available() else "cpu") |
| 244 | return LearnableAdaptiveMask(config, device=device) |
| 245 | if config.strategy == "gradient": |
| 246 | return GradientAdaptiveMask(config) |
| 247 | raise ValueError(f"Unsupported mask strategy '{config.strategy}'") |