---
description: Explore Ultralytics-tailored torch utility features like Model EMA, early stopping, smart inference, image scaling, get_flops, and many more.
keywords: Ultralytics, Torch Utils, Model EMA, Early Stopping, Smart Inference, Get CPU Info, Time Sync, Fuse Deconv and bn, Get num params, Get FLOPs, Scale img, Copy attr, Intersect dicts, De_parallel, Init seeds, Profile
---
# Reference for `ultralytics/utils/torch_utils.py`
!!! Note
This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/torch_utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/torch_utils.py). If you spot a problem please help fix it by [contributing](https://docs.ultralytics.com/help/contributing/) a [Pull Request](https://github.com/ultralytics/ultralytics/edit/main/ultralytics/utils/torch_utils.py) 🛠️. Thank you 🙏!
## ::: ultralytics.utils.torch_utils.ModelEMA
## ::: ultralytics.utils.torch_utils.EarlyStopping
## ::: ultralytics.utils.torch_utils.torch_distributed_zero_first
## ::: ultralytics.utils.torch_utils.smart_inference_mode
## ::: ultralytics.utils.torch_utils.get_cpu_info
## ::: ultralytics.utils.torch_utils.select_device
## ::: ultralytics.utils.torch_utils.time_sync
## ::: ultralytics.utils.torch_utils.fuse_conv_and_bn
## ::: ultralytics.utils.torch_utils.fuse_deconv_and_bn
## ::: ultralytics.utils.torch_utils.model_info
## ::: ultralytics.utils.torch_utils.get_num_params
## ::: ultralytics.utils.torch_utils.get_num_gradients
## ::: ultralytics.utils.torch_utils.model_info_for_loggers
## ::: ultralytics.utils.torch_utils.get_flops
## ::: ultralytics.utils.torch_utils.get_flops_with_torch_profiler
## ::: ultralytics.utils.torch_utils.initialize_weights
## ::: ultralytics.utils.torch_utils.scale_img
## ::: ultralytics.utils.torch_utils.make_divisible
## ::: ultralytics.utils.torch_utils.copy_attr
## ::: ultralytics.utils.torch_utils.get_latest_opset
## ::: ultralytics.utils.torch_utils.intersect_dicts
## ::: ultralytics.utils.torch_utils.is_parallel
## ::: ultralytics.utils.torch_utils.de_parallel
## ::: ultralytics.utils.torch_utils.one_cycle
## ::: ultralytics.utils.torch_utils.init_seeds
## ::: ultralytics.utils.torch_utils.strip_optimizer
## ::: ultralytics.utils.torch_utils.profile