


'''simple docstring'''




import argparse

import torch

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


logging.set_verbosity_info()





def 	a_					( lowerCamelCase	:     Tuple	, lowerCamelCase	:     Dict	, lowerCamelCase	:     Tuple				):
   # Initialise PyTorch model
   lowerCAmelCase     =			AlbertConfig.from_json_file(lowerCamelCase				)
   print(f'''Building PyTorch model from configuration: {config}'''				)
   lowerCAmelCase     =			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__":
       __snake_case    						=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."""
       )
       __snake_case    						=parser.parse_args()
       convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.albert_config_file, args.pytorch_dump_path)









'''simple docstring'''




class 		UpperCAmelCase_      :





     def __init__( self       :      List[str]    ,      UpperCAmelCase__       :      list[int]    )				->  None:
        lowerCAmelCase     =			len(UpperCAmelCase__    )
        lowerCAmelCase     =			[0] * len_array

        if len_array > 0:
           lowerCAmelCase     =			array[0]

        for i in range(1    ,      UpperCAmelCase__    ):
           lowerCAmelCase     =			self.prefix_sum[i - 1] + array[i]





     def 							__UpperCAmelCase      ( self       :      Optional[Any]    ,      UpperCAmelCase__       :      int    ,      UpperCAmelCase__       :      int    )				->  int:
        if start == 0:
           return self.prefix_sum[end]

        return self.prefix_sum[end] - self.prefix_sum[start - 1]





     def 							__UpperCAmelCase      ( self       :      int    ,      UpperCAmelCase__       :      int    )				->  bool:
        lowerCAmelCase     =			{0}
        for sum_item in self.prefix_sum:
           if sum_item - target_sum in sums:
              return True

           sums.add(UpperCAmelCase__    )

        return False


if __name__ == "__main__":
       import doctest

       doctest.testmod()





