"""
Timer context manager, only used in debug.
"""fromtimeimporttimeimportcontextlibfromtypingimportGenerator@contextlib.contextmanagerdeftimer(subject:str="time")->Generator[None, None, None]:"""print the elapsed time. (only used in debugging)"""start=time()yieldelapsed=time()-startelapsed_ms=elapsed*1000print(f"{subject} elapsed {elapsed_ms:.1f}ms")