--- description: Explore the detailed API reference for Ultralytics SAM and SAM 2 models. keywords: Ultralytics, SAM, SAM 2, API Reference, models, window partition, data processing, YOLO --- # Reference for `ultralytics/models/sam/modules/utils.py` !!! note This file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/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/models/sam/modules/utils.py) 🛠️. Thank you 🙏!
## ::: ultralytics.models.sam.modules.utils.select_closest_cond_frames



## ::: ultralytics.models.sam.modules.utils.get_1d_sine_pe



## ::: ultralytics.models.sam.modules.utils.init_t_xy



## ::: ultralytics.models.sam.modules.utils.compute_axial_cis



## ::: ultralytics.models.sam.modules.utils.reshape_for_broadcast



## ::: ultralytics.models.sam.modules.utils.apply_rotary_enc



## ::: ultralytics.models.sam.modules.utils.window_partition



## ::: ultralytics.models.sam.modules.utils.window_unpartition



## ::: ultralytics.models.sam.modules.utils.get_rel_pos



## ::: ultralytics.models.sam.modules.utils.add_decomposed_rel_pos