
"""simple docstring"""







import importlib.metadata
from typing import Union

from packaging.version import Version, parse

from .constants import STR_OPERATION_TO_FUNC


lowerCamelCase__        =		parse(importlib.metadata.version("""torch"""))
def    __lowerCAmelCase    (_UpperCamelCase	,  _UpperCamelCase	,  _UpperCamelCase		):
	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}"		)
	__lowerCAmelCase      :						Union[str, Any]						      =				STR_OPERATION_TO_FUNC[operation]
	if isinstance(_UpperCamelCase	,  _UpperCamelCase		):
		__lowerCAmelCase      :						List[Any]						      =				parse(importlib.metadata.version(_UpperCamelCase		)		)
	return operation(_UpperCamelCase	,  parse(_UpperCamelCase		)		)
def    __lowerCAmelCase    (_UpperCamelCase	,  _UpperCamelCase		):
	return compare_versions(_UpperCamelCase	,  _UpperCamelCase	,  _UpperCamelCase		)

"""simple docstring"""







from typing import Optional
from urllib.parse import quote

import huggingface_hub as hfh
from packaging import version
def    __lowerCAmelCase    (_UpperCamelCase	,  _UpperCamelCase	,  _UpperCamelCase = None		):
	if version.parse(hfh.__version__		).release < version.parse('0.11.0'		).release:
		# old versions of hfh don't url-encode the file path
		__lowerCAmelCase      :						List[str]						      =				quote(_UpperCamelCase		)
	return hfh.hf_hub_url(_UpperCamelCase	,  _UpperCamelCase	,  repo_type='dataset'	,  revision=_UpperCamelCase		)