"""ZeroGPU shim. On a ZeroGPU Space `gpu` is `spaces.GPU`; anywhere else it is a no-op, so the same code runs locally and on-prem. Import this module BEFORE torch.""" try: import spaces # type: ignore gpu = spaces.GPU ON_ZERO_GPU = True except Exception: # not on HF, or `spaces` not installed ON_ZERO_GPU = False def gpu(*args, **kwargs): if len(args) == 1 and callable(args[0]) and not kwargs: return args[0] def deco(fn): return fn return deco