autocast region (e.g. forward outside AMP, backward under ``autocast(bf16)``), and a null context would let that ambient state leak into the replay, changing recomputed tensor dtypes. """ifkwargsisNone:returncontextlib.nullcontext()returntorch.amp.autocast(device_type=device_type,**kwargs)