Fix training speed regression introduced by "optimize VRAM for calculating pos_bias in LayoutLM v2, v3 (#26139)" (#30988)
* Revert "optimize VRAM for calculating pos_bias in LayoutLM v2, v3 (#26139)"
This reverts commit a7e0ed829c398a67a641a401e23dae13e2f8b217.
* Instead of reverting commit, wrap indexing in torch.no_grad context
* Apply wrapping in LayoutLMv2
* Add comments explaining reason for no_grad
* Fix code format
---------
Co-authored-by: Kevin Koehncke <kevin.koehncke@uipath.com>