






import importlib.metadata
from typing import Union

from packaging.version import Version, parse

from .constants import STR_OPERATION_TO_FUNC


lowerCamelCase : Optional[Any]						   =       parse(importlib.metadata.version('''torch'''))
def       snake_case_		(     lowerCAmelCase_       :						Union[str, Version]       ,       lowerCAmelCase_       :						str       ,       lowerCAmelCase_       :						str      ):
							if operation not in STR_OPERATION_TO_FUNC.keys():
														raise ValueError(F"`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys()      )}, received {operation}"      )
							__lowercase      :							Optional[Any]				=     STR_OPERATION_TO_FUNC[operation]
							if isinstance(lowerCAmelCase_       ,       lowerCAmelCase_      ):
														__lowercase      :							Any				=     parse(importlib.metadata.version(lowerCAmelCase_      )      )
							return operation(lowerCAmelCase_       ,       parse(lowerCAmelCase_      )      )



def       snake_case_		(     lowerCAmelCase_       :						str       ,       lowerCAmelCase_       :						str      ):
							return compare_versions(lowerCAmelCase_       ,       lowerCAmelCase_       ,       lowerCAmelCase_      )







from .imports import is_tqdm_available


if is_tqdm_available():
	from tqdm.auto import tqdm as _tqdm

from ..state import PartialState
def       snake_case_		(     lowerCAmelCase_       :						bool = True       ,       *lowerCAmelCase_       :						int       ,       **lowerCAmelCase_       :						List[str]      ):
							if not is_tqdm_available():
														raise ImportError("""Accelerate's `tqdm` module requires `tqdm` to be installed. Please run `pip install tqdm`."""      )
							__lowercase      :							List[str]				=     False
							if main_process_only:
														__lowercase      :							Optional[int]				=     PartialState().local_process_index == 0
							return _tqdm(*lowerCAmelCase_       ,       **lowerCAmelCase_       ,       disable=lowerCAmelCase_      )