


'''simple docstring'''




import argparse

import torch

from ...utils import logging
from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert


logging.set_verbosity_info()


def    UpperCAmelCase_  (       A		,	A		,	A      ):
   '''simple docstring'''





   _a					:  List[Any]						=  AlbertConfig.from_json_file(_lowerCamelCase      )
   print(f'''Building PyTorch model from configuration: {config}'''      )
   _a					:  Tuple						=  AlbertForPreTraining(_lowerCamelCase      )

   # Load weights from tf checkpoint
   load_tf_weights_in_albert(_lowerCamelCase		,	_lowerCamelCase		,	_lowerCamelCase      )

   # Save pytorch-model
   print(f'''Save PyTorch model to {pytorch_dump_path}'''      )
   torch.save(model.state_dict()		,	_lowerCamelCase      )


if __name__ == "__main__":
 UpperCAmelCase_      :		List[Any]          =		argparse.ArgumentParser()
 # Required parameters
 parser.add_argument(
     "--tf_checkpoint_path", default=None, type=str, required=True, help="Path to the TensorFlow checkpoint path."
 )
 parser.add_argument(
     "--albert_config_file",
     default=None,
     type=str,
     required=True,
     help=(
         "The config json file corresponding to the pre-trained ALBERT model. \n"
         "This specifies the model architecture."
     ),
 )
 parser.add_argument(
     "--pytorch_dump_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
 )
 UpperCAmelCase_      :		Optional[Any]          =		parser.parse_args()
 convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.albert_config_file, args.pytorch_dump_path)








'''simple docstring'''



from typing import Optional

import pyspark

from .. import Features, NamedSplit
from ..download import DownloadMode
from ..packaged_modules.spark.spark import Spark
from .abc import AbstractDatasetReader





class      lowerCAmelCase (			__lowerCAmelCase):


       def __init__( self     ,	__SCREAMING_SNAKE_CASE     ,	__SCREAMING_SNAKE_CASE = None     ,	__SCREAMING_SNAKE_CASE = None     ,	__SCREAMING_SNAKE_CASE = True     ,	__SCREAMING_SNAKE_CASE = None     ,	__SCREAMING_SNAKE_CASE = False     ,	__SCREAMING_SNAKE_CASE = None     ,	__SCREAMING_SNAKE_CASE = True     ,	__SCREAMING_SNAKE_CASE = "arrow"     ,	**__SCREAMING_SNAKE_CASE     ,	)   ->	Union[str, Any]:



            '''simple docstring'''




            super().__init__(
                split=__SCREAMING_SNAKE_CASE     ,	features=__SCREAMING_SNAKE_CASE     ,	cache_dir=__SCREAMING_SNAKE_CASE     ,	keep_in_memory=__SCREAMING_SNAKE_CASE     ,	streaming=__SCREAMING_SNAKE_CASE     ,	**__SCREAMING_SNAKE_CASE     ,	)
            __snake_case            =	load_from_cache_file
            __snake_case            =	file_format
            __snake_case            =	Spark(
                df=__SCREAMING_SNAKE_CASE     ,	features=__SCREAMING_SNAKE_CASE     ,	cache_dir=__SCREAMING_SNAKE_CASE     ,	working_dir=__SCREAMING_SNAKE_CASE     ,	**__SCREAMING_SNAKE_CASE     ,	)




       def    lowerCAmelCase   ( self	)   ->	str:



            '''simple docstring'''




            if self.streaming:
                 return self.builder.as_streaming_dataset(split=self.split	)
            __snake_case            =	None if self._load_from_cache_file else DownloadMode.FORCE_REDOWNLOAD
            self.builder.download_and_prepare(
                download_mode=__SCREAMING_SNAKE_CASE     ,	file_format=self._file_format     ,	)
            return self.builder.as_dataset(split=self.split	)






