


'''simple docstring'''






import time
from contextlib import contextmanager
from pathlib import Path

import pytest
import requests
from huggingface_hub.hf_api import HfApi, HfFolder


a_					:    Tuple          =    "__DUMMY_TRANSFORMERS_USER__"
a_					:    List[Any]          =    "Dummy User"
a_					:    str          =    "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"

a_					:    Optional[int]          =    "https://hub-ci.huggingface.co"
a_					:    Any          =    CI_HUB_ENDPOINT + "/datasets/{repo_id}/resolve/{revision}/{path}"
a_					:    Tuple          =    CI_HUB_ENDPOINT + "/{repo_id}/resolve/{revision}/{filename}"
a_					:    Union[str, Any]          =    Path("~/.huggingface/hub_ci_token").expanduser()






@pytest.fixture
def 	_A				(lowerCAmelCase__  :Optional[int]		)   ->  Tuple:




     '''simple docstring'''



     monkeypatch.setattr(
         'huggingface_hub.file_download.HUGGINGFACE_CO_URL_TEMPLATE'				,						lowerCAmelCase__		)






@pytest.fixture
def 	_A				(lowerCAmelCase__  :Dict		)   ->  Union[str, Any]:




     '''simple docstring'''



     monkeypatch.setattr('datasets.config.HF_ENDPOINT'				,						lowerCAmelCase__		)
     monkeypatch.setattr('datasets.config.HUB_DATASETS_URL'				,						lowerCAmelCase__		)






@pytest.fixture
def 	_A				(lowerCAmelCase__  :Tuple		)   ->  Tuple:




     '''simple docstring'''



     monkeypatch.setattr('huggingface_hub.hf_api.HfFolder.path_token'				,						lowerCAmelCase__		)






@pytest.fixture
def 	_A				(lowerCAmelCase__  :Optional[Any]				,						lowerCAmelCase__  :Optional[Any]		)   ->  Union[str, Any]:




     '''simple docstring'''



     HfFolder.save_token(lowerCAmelCase__		)
     yield
     HfFolder.delete_token()






@pytest.fixture(scope='session'		)
def 	_A				()   ->  Optional[Any]:




     '''simple docstring'''



     return HfApi(endpoint=lowerCAmelCase__		)






@pytest.fixture(scope='session'		)
def 	_A				(lowerCAmelCase__  :HfApi		)   ->  Any:




     '''simple docstring'''



     _a			      =							HfFolder.get_token()
     HfFolder.save_token(lowerCAmelCase__		)
     yield CI_HUB_USER_TOKEN
     if previous_token is not None:
          HfFolder.save_token(lowerCAmelCase__		)






@pytest.fixture
def 	_A				(lowerCAmelCase__  :str		)   ->  str:




     '''simple docstring'''



     def _cleanup_repo(lowerCAmelCase__  :List[Any]		):
          hf_api.delete_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'		)

     return _cleanup_repo






@pytest.fixture
def 	_A				(lowerCAmelCase__  :Optional[int]		)   ->  List[str]:




     '''simple docstring'''



     @contextmanager
     def _temporary_repo(lowerCAmelCase__  :List[str]		):
          try:
               yield repo_id
          finally:
               cleanup_repo(lowerCAmelCase__		)

     return _temporary_repo






@pytest.fixture(scope='session'		)
def 	_A				(lowerCAmelCase__  :HfApi				,						lowerCAmelCase__  :List[Any]				,						lowerCAmelCase__  :List[Any]		)   ->  List[Any]:




     '''simple docstring'''



     _a			      =							f'repo_txt_data-{int(time.time() * 10E3		)}'
     _a			      =							f'{CI_HUB_USER}/{repo_name}'
     hf_api.create_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'				,						private=lowerCAmelCase__		)
     hf_api.upload_file(
         token=lowerCAmelCase__				,						path_or_fileobj=str(lowerCAmelCase__		)				,						path_in_repo='data/text_data.txt'				,						repo_id=lowerCAmelCase__				,						repo_type='dataset'				,						)
     yield repo_id
     try:
          hf_api.delete_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'		)
     except (requests.exceptions.HTTPError, ValueError):  # catch http error and token invalid error
          pass






@pytest.fixture()
def 	_A				(lowerCAmelCase__  :Tuple				,						lowerCAmelCase__  :Optional[int]				,						lowerCAmelCase__  :List[str]		)   ->  Optional[int]:




     '''simple docstring'''



     return hf_private_dataset_repo_txt_data_






@pytest.fixture(scope='session'		)
def 	_A				(lowerCAmelCase__  :HfApi				,						lowerCAmelCase__  :List[Any]				,						lowerCAmelCase__  :Dict		)   ->  Any:




     '''simple docstring'''



     _a			      =							f'repo_zipped_txt_data-{int(time.time() * 10E3		)}'
     _a			      =							f'{CI_HUB_USER}/{repo_name}'
     hf_api.create_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'				,						private=lowerCAmelCase__		)
     hf_api.upload_file(
         token=lowerCAmelCase__				,						path_or_fileobj=str(lowerCAmelCase__		)				,						path_in_repo='data.zip'				,						repo_id=lowerCAmelCase__				,						repo_type='dataset'				,						)
     yield repo_id
     try:
          hf_api.delete_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'		)
     except (requests.exceptions.HTTPError, ValueError):  # catch http error and token invalid error
          pass






@pytest.fixture()
def 	_A				(lowerCAmelCase__  :Dict				,						lowerCAmelCase__  :Union[str, Any]				,						lowerCAmelCase__  :Any		)   ->  Any:




     '''simple docstring'''



     return hf_private_dataset_repo_zipped_txt_data_






@pytest.fixture(scope='session'		)
def 	_A				(lowerCAmelCase__  :HfApi				,						lowerCAmelCase__  :str				,						lowerCAmelCase__  :Tuple		)   ->  Dict:




     '''simple docstring'''



     _a			      =							f'repo_zipped_img_data-{int(time.time() * 10E3		)}'
     _a			      =							f'{CI_HUB_USER}/{repo_name}'
     hf_api.create_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'				,						private=lowerCAmelCase__		)
     hf_api.upload_file(
         token=lowerCAmelCase__				,						path_or_fileobj=str(lowerCAmelCase__		)				,						path_in_repo='data.zip'				,						repo_id=lowerCAmelCase__				,						repo_type='dataset'				,						)
     yield repo_id
     try:
          hf_api.delete_repo(lowerCAmelCase__				,						token=lowerCAmelCase__				,						repo_type='dataset'		)
     except (requests.exceptions.HTTPError, ValueError):  # catch http error and token invalid error
          pass






@pytest.fixture()
def 	_A				(lowerCAmelCase__  :List[Any]				,						lowerCAmelCase__  :str				,						lowerCAmelCase__  :Union[str, Any]		)   ->  Dict:




     '''simple docstring'''



     return hf_private_dataset_repo_zipped_img_data_





'''simple docstring'''






from typing import Any






def 	_A				(lowerCAmelCase__  :list		)   ->  list[Any]:




     '''simple docstring'''



     if not input_list:
          return []
     _a			      =							[input_list.count(lowerCAmelCase__		) for value in input_list]
     _a			      =							max(lowerCAmelCase__		)  # Gets the maximum count in the input list.
     # Gets values of modes
     return sorted({input_list[i] for i, value in enumerate(lowerCAmelCase__		) if value == y}		)


if __name__ == "__main__":
 import doctest

 doctest.testmod()

