--- description: Explore valuable torch utilities from Ultralytics for optimized model performance, including device selection, model fusion, and inference optimization. keywords: Ultralytics, torch utils, model optimization, device selection, inference optimization, model fusion, CPU info, PyTorch tools --- # 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.convert_optimizer_state_dict_to_fp16

## ::: ultralytics.utils.torch_utils.profile