


"""simple docstring"""



__snake_case       =       """0.21.0"""

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
  from .utils import rich









"""simple docstring"""



import argparse

import torch

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


logging.set_verbosity_info()







def     __lowerCAmelCase		(		lowercase    :    List[Any]		,				lowercase    :    Dict		,				lowercase    :    str					)      ->		Optional[int]:


    """simple docstring"""





    snake_case       : Tuple    =       AlbertConfig.from_json_file(lowercase					)
    print(F'Building PyTorch model from configuration: {config}'					)
    snake_case       : int    =       AlbertForPreTraining(lowercase					)

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

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


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)





