
"""simple docstring"""




import pytest

import datasets


# Import fixture modules as plugins
A__      :	List[Any]          =    ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""]



def 							a__ (				lowerCAmelCase	:       Dict       ,    lowerCAmelCase	:       List[str]		):






     '''simple docstring'''
     # Mark tests as "unit" by default if not marked as "integration" (or already marked as "unit")
     for item in items:
          if any(marker in item.keywords for marker in ["integration", "unit"]		):
               continue
          item.add_marker(pytest.mark.unit		)



def 							a__ (				lowerCAmelCase	:       Optional[Any]		):






     '''simple docstring'''
     config.addinivalue_line("markers"       ,    "torchaudio_latest: mark test to run with torchaudio>=0.12"		)



@pytest.fixture(autouse=lowerCAmelCase		)
def 							a__ (				lowerCAmelCase	:       Union[str, Any]       ,    lowerCAmelCase	:       int		):






     '''simple docstring'''
     # test_hf_cache_home = tmp_path_factory.mktemp("cache")  # TODO: why a cache dir per test function does not work?
     UpperCAmelCase__							: Union[str, Any] 							=						tmp_path_factory.getbasetemp() / "cache"
     UpperCAmelCase__							: Optional[Any] 							=						test_hf_cache_home / "datasets"
     UpperCAmelCase__							: List[Any] 							=						test_hf_cache_home / "metrics"
     UpperCAmelCase__							: List[Any] 							=						test_hf_cache_home / "modules"
     monkeypatch.setattr("datasets.config.HF_DATASETS_CACHE"       ,    str(lowerCAmelCase		)		)
     monkeypatch.setattr("datasets.config.HF_METRICS_CACHE"       ,    str(lowerCAmelCase		)		)
     monkeypatch.setattr("datasets.config.HF_MODULES_CACHE"       ,    str(lowerCAmelCase		)		)
     UpperCAmelCase__							: str 							=						test_hf_datasets_cache / "downloads"
     monkeypatch.setattr("datasets.config.DOWNLOADED_DATASETS_PATH"       ,    str(lowerCAmelCase		)		)
     UpperCAmelCase__							: str 							=						test_hf_datasets_cache / "downloads" / "extracted"
     monkeypatch.setattr("datasets.config.EXTRACTED_DATASETS_PATH"       ,    str(lowerCAmelCase		)		)



@pytest.fixture(autouse=lowerCAmelCase       ,    scope="session"		)
def 							a__ (				):






     '''simple docstring'''
     datasets.disable_progress_bar()



@pytest.fixture(autouse=lowerCAmelCase		)
def 							a__ (				lowerCAmelCase	:       Optional[int]		):






     '''simple docstring'''
     # don't take tests into account when counting downloads
     monkeypatch.setattr("datasets.config.HF_UPDATE_DOWNLOAD_COUNTS"       ,    lowerCAmelCase		)



@pytest.fixture
def 							a__ (				lowerCAmelCase	:       str		):






     '''simple docstring'''
     # Required to suppress RemovedIn20Warning when feature(s) are not compatible with SQLAlchemy 2.0
     # To be removed once SQLAlchemy 2.0 supported
     monkeypatch.setattr("sqlalchemy.util.deprecations.SILENCE_UBER_WARNING"       ,    lowerCAmelCase		)





"""simple docstring"""




import argparse
import os

import torch

from transformers.utils import WEIGHTS_NAME


A__      :	Optional[int]          =    ["""small""", """medium""", """large"""]

A__      :	Optional[int]          =    """lm_head.decoder.weight"""
A__      :	Dict          =    """lm_head.weight"""



def 							a__ (				lowerCAmelCase	:       str       ,    lowerCAmelCase	:       str		):






     '''simple docstring'''
     UpperCAmelCase__							: Dict 							=						torch.load(lowerCAmelCase		)
     UpperCAmelCase__							: Optional[int] 							=						d.pop(lowerCAmelCase		)
     os.makedirs(lowerCAmelCase       ,    exist_ok=lowerCAmelCase		)
     torch.save(lowerCAmelCase       ,    os.path.join(lowerCAmelCase       ,    lowerCAmelCase		)		)


if __name__ == "__main__":
    A__      :	List[Any]          =    argparse.ArgumentParser()
    parser.add_argument("""--dialogpt_path""", default=""".""", type=str)
    A__      :	Tuple          =    parser.parse_args()
    for MODEL in DIALOGPT_MODELS:
        A__      :	Tuple          =    os.path.join(args.dialogpt_path, f"""{MODEL}_ft.pkl""")
        A__      :	str          =    f"""./DialoGPT-{MODEL}"""
        convert_dialogpt_checkpoint(
            checkpoint_path,
            pytorch_dump_folder_path,
        )



