



import argparse
import os

import torch

from transformers.utils import WEIGHTS_NAME


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

a__   :					List[str] 						=      "lm_head.decoder.weight"
a__   :					Optional[Any] 						=      "lm_head.weight"

def 	_lowerCAmelCase (    A__    ,	A__						):
      lowercase__  =	torch.load(A__						)
      lowercase__  =	d.pop(A__						)
      os.makedirs(A__    ,	exist_ok=A__						)
      torch.save(A__    ,	os.path.join(A__    ,	A__						)						)


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





import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline

@pytest.mark.integration
def 	_lowerCAmelCase (    ):
      with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT						):
            with pytest.raises(A__						):
                  requests.request('GET'    ,	'https://huggingface.co'						)
            with pytest.raises(requests.exceptions.ConnectTimeout						):
                  requests.request('GET'    ,	'https://huggingface.co'    ,	timeout=1.0						)

@pytest.mark.integration
def 	_lowerCAmelCase (    ):
      with offline(OfflineSimulationMode.CONNECTION_FAILS						):
            with pytest.raises(requests.exceptions.ConnectionError						):
                  requests.request('GET'    ,	'https://huggingface.co'						)

def 	_lowerCAmelCase (    ):
      with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1						):
            with pytest.raises(A__						):
                  http_head('https://huggingface.co'						)
