



# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import os

from accelerate.test_utils import execute_subprocess_async





def 		a__			(		_UpperCamelCase			: List[str]=None							):
   if subparsers is not None:
      __lowerCamelCase													=    subparsers.add_parser('''test'''							)
   else:
      __lowerCamelCase													=    argparse.ArgumentParser('''Accelerate test command'''							)

   parser.add_argument(
       '''--config_file''' ,default=_UpperCamelCase ,help=(
           '''The path to use to store the config file. Will default to a file named default_config.yaml in the cache '''
           '''location, which is the content of the environment `HF_HOME` suffixed with \'accelerate\', or if you don\'t have '''
           '''such an environment variable, your cache directory (\'~/.cache\' or the content of `XDG_CACHE_HOME`) suffixed '''
           '''with \'huggingface\'.'''
       ) ,)

   if subparsers is not None:
      parser.set_defaults(func=_UpperCamelCase							)
   return parser





def 		a__			(		_UpperCamelCase			: Optional[Any]							):
   __lowerCamelCase													=    os.path.sep.join(__file__.split(os.path.sep							)[:-2] + ['''test_utils''', '''scripts''', '''test_script.py''']							)

   if args.config_file is None:
      __lowerCamelCase													=    script_name
   else:
      __lowerCamelCase													=    F"""--config_file={args.config_file} {script_name}"""

   __lowerCamelCase													=    ['''accelerate-launch'''] + test_args.split()
   __lowerCamelCase													=    execute_subprocess_async(_UpperCamelCase ,env=os.environ.copy()							)
   if result.returncode == 0:
      print('''Test is a success! You are ready for your distributed training!'''							)





def 		a__			(		):
   __lowerCamelCase													=    test_command_parser()
   __lowerCamelCase													=    parser.parse_args()
   test_command(_UpperCamelCase							)


if __name__ == "__main__":
  main()











from ...configuration_utils import PretrainedConfig
from ...utils import logging


a_			=					logging.get_logger(__name__)

a_			=					{
    """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""",
}



class  __lowerCAmelCase     (	lowerCAmelCase__   ):
 lowerCAmelCase__       					=  """lxmert"""
 lowerCAmelCase__       					=  {}




 def __init__(						self	,				__UpperCAmelCase=30522	,				__UpperCAmelCase=768	,				__UpperCAmelCase=12	,				__UpperCAmelCase=9500	,				__UpperCAmelCase=1600	,				__UpperCAmelCase=400	,				__UpperCAmelCase=3072	,				__UpperCAmelCase="gelu"	,				__UpperCAmelCase=0.1	,				__UpperCAmelCase=0.1	,				__UpperCAmelCase=512	,				__UpperCAmelCase=2	,				__UpperCAmelCase=0.02	,				__UpperCAmelCase=1E-1_2	,				__UpperCAmelCase=9	,				__UpperCAmelCase=5	,				__UpperCAmelCase=5	,				__UpperCAmelCase=2048	,				__UpperCAmelCase=4	,				__UpperCAmelCase=6.67	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				__UpperCAmelCase=True	,				**__UpperCAmelCase	,				):



    '''simple docstring'''
    __lowerCamelCase													=    vocab_size
    __lowerCamelCase													=    hidden_size
    __lowerCamelCase													=    num_attention_heads
    __lowerCamelCase													=    hidden_act
    __lowerCamelCase													=    intermediate_size
    __lowerCamelCase													=    hidden_dropout_prob
    __lowerCamelCase													=    attention_probs_dropout_prob
    __lowerCamelCase													=    max_position_embeddings
    __lowerCamelCase													=    type_vocab_size
    __lowerCamelCase													=    initializer_range
    __lowerCamelCase													=    layer_norm_eps
    __lowerCamelCase													=    num_qa_labels
    __lowerCamelCase													=    num_object_labels
    __lowerCamelCase													=    num_attr_labels
    __lowerCamelCase													=    l_layers
    __lowerCamelCase													=    x_layers
    __lowerCamelCase													=    r_layers
    __lowerCamelCase													=    visual_feat_dim
    __lowerCamelCase													=    visual_pos_dim
    __lowerCamelCase													=    visual_loss_normalizer
    __lowerCamelCase													=    task_matched
    __lowerCamelCase													=    task_mask_lm
    __lowerCamelCase													=    task_obj_predict
    __lowerCamelCase													=    task_qa
    __lowerCamelCase													=    visual_obj_loss
    __lowerCamelCase													=    visual_attr_loss
    __lowerCamelCase													=    visual_feat_loss
    __lowerCamelCase													=    {'''vision''': r_layers, '''cross_encoder''': x_layers, '''language''': l_layers}
    super().__init__(**__UpperCAmelCase				)






