perf: Remove implicit CPU-GPU syncs due to implicit .item() call (#42433)
* perf: Remove implicit CPU-GPU syncs due to implicit .item() call
* fix: replicated the changes across similar files
* fix: update the newly added nanochat model files
* fix: use input_shape and device instead of input_emdeds properties for imagegpt