





"""simple docstring"""
import importlib
import os
import sys


# This is required to make the module import works (when the python process is running from the root of the repo)
sys.path.append('''.''')

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    List[Any]			):
 lowerCAmelCase    				= test_file.split(os.path.sep			)
 if components[0:2] != ["tests", "models"]:
  raise ValueError(
      '`test_file` should start with `tests/models/` (with `/` being the OS specific path separator). Got '
      F'{test_file} instead.'			)
 lowerCAmelCase    				= components[-1]
 if not test_fn.endswith('py'			):
  raise ValueError(F'`test_file` should be a python file. Got {test_fn} instead.'			)
 if not test_fn.startswith('test_modeling_'			):
  raise ValueError(
      F'`test_file` should point to a file name of the form `test_modeling_*.py`. Got {test_fn} instead.'			)

 lowerCAmelCase    				= components[:-1] + [test_fn.replace('.py'  ,     ''			)]
 lowerCAmelCase    				= '.'.join(_UpperCAmelCase			)

 return test_module_path

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Tuple			):
 lowerCAmelCase    				= get_module_path(_UpperCAmelCase			)
 lowerCAmelCase    				= importlib.import_module(_UpperCAmelCase			)

 return test_module

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Dict			):
 lowerCAmelCase    				= []
 lowerCAmelCase    				= get_test_module(_UpperCAmelCase			)
 for attr in dir(_UpperCAmelCase			):
  if attr.endswith('ModelTester'			):
   tester_classes.append(getattr(_UpperCAmelCase  ,     _UpperCAmelCase			)			)

    # sort with class names
 return sorted(_UpperCAmelCase  ,     key=lambda _UpperCAmelCase			: x.__name__			)

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Union[str, Any]			):
 lowerCAmelCase    				= []
 lowerCAmelCase    				= get_test_module(_UpperCAmelCase			)
 for attr in dir(_UpperCAmelCase			):
  lowerCAmelCase    				= getattr(_UpperCAmelCase  ,     _UpperCAmelCase			)
  # (TF/Flax)ModelTesterMixin is also an attribute in specific model test module. Let's exclude them by checking
  # `all_model_classes` is not empty (which also excludes other special classes).
  lowerCAmelCase    				= getattr(_UpperCAmelCase  ,     'all_model_classes'  ,     []			)
  if len(_UpperCAmelCase			) > 0:
   test_classes.append(_UpperCAmelCase			)

    # sort with class names
 return sorted(_UpperCAmelCase  ,     key=lambda _UpperCAmelCase			: x.__name__			)

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Dict			):
 lowerCAmelCase    				= get_test_classes(_UpperCAmelCase			)
 lowerCAmelCase    				= set()
 for test_class in test_classes:
  model_classes.update(test_class.all_model_classes			)

 # sort with class names
 return sorted(_UpperCAmelCase  ,     key=lambda _UpperCAmelCase			: x.__name__			)

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    List[str]			):
 lowerCAmelCase    				= test_class()
 if hasattr(_UpperCAmelCase  ,     'setUp'			):
  test.setUp()

 lowerCAmelCase    				= None
 if hasattr(_UpperCAmelCase  ,     'model_tester'			):
  # `(TF/Flax)ModelTesterMixin` has this attribute default to `None`. Let's skip this case.
  if test.model_tester is not None:
   lowerCAmelCase    				= test.model_tester.__class__

 return model_tester

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    int  ,     _UpperCAmelCase					:    Union[str, Any]			):
 lowerCAmelCase    				= get_test_classes(_UpperCAmelCase			)

 lowerCAmelCase    				= []
 for test_class in test_classes:
  if model_class in test_class.all_model_classes:
   target_test_classes.append(_UpperCAmelCase			)

    # sort with class names
 return sorted(_UpperCAmelCase  ,     key=lambda _UpperCAmelCase			: x.__name__			)

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    List[str]  ,     _UpperCAmelCase					:    int			):
 lowerCAmelCase    				= get_test_classes_for_model(_UpperCAmelCase  ,     _UpperCAmelCase			)

 lowerCAmelCase    				= []
 for test_class in test_classes:
  lowerCAmelCase    				= get_model_tester_from_test_class(_UpperCAmelCase			)
  if tester_class is not None:
   tester_classes.append(_UpperCAmelCase			)

    # sort with class names
 return sorted(_UpperCAmelCase  ,     key=lambda _UpperCAmelCase			: x.__name__			)

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    int			):
 lowerCAmelCase    				= get_test_classes(_UpperCAmelCase			)
 lowerCAmelCase    				= {test_class: get_model_tester_from_test_class(_UpperCAmelCase			) for test_class in test_classes}
 return test_tester_mapping

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Any			):
 lowerCAmelCase    				= get_model_classes(_UpperCAmelCase			)
 lowerCAmelCase    				= {
     model_class: get_test_classes_for_model(_UpperCAmelCase  ,     _UpperCAmelCase			) for model_class in model_classes
 }
 return model_test_mapping

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Tuple			):
 lowerCAmelCase    				= get_model_classes(_UpperCAmelCase			)
 lowerCAmelCase    				= {
     model_class: get_tester_classes_for_model(_UpperCAmelCase  ,     _UpperCAmelCase			) for model_class in model_classes
 }
 return model_to_tester_mapping




def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Optional[Any]			):
 if isinstance(_UpperCAmelCase  ,     _UpperCAmelCase			):
  return o
 elif isinstance(_UpperCAmelCase  ,     _UpperCAmelCase			):
  return o.__name__
 elif isinstance(_UpperCAmelCase  ,     (list, tuple)			):
  return [to_json(_UpperCAmelCase			) for x in o]
 elif isinstance(_UpperCAmelCase  ,     _UpperCAmelCase			):
  return {to_json(_UpperCAmelCase			): to_json(_UpperCAmelCase			) for k, v in o.items()}
 else:
  return o












"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCamelCase     :						Optional[Any]						       =  logging.get_logger(__name__)

__UpperCamelCase     :						List[Any]						       =  {
    # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert
}







class       a							(   a__  ):
 snake_case__             =       '''megatron-bert'''



 def __init__(     self				,       _snake_case=2_90_56				,       _snake_case=10_24				,       _snake_case=24				,       _snake_case=16				,       _snake_case=40_96				,       _snake_case="gelu"				,       _snake_case=0.1				,       _snake_case=0.1				,       _snake_case=5_12				,       _snake_case=2				,       _snake_case=0.02				,       _snake_case=1E-12				,       _snake_case=0				,       _snake_case="absolute"				,       _snake_case=True				,       **_snake_case				,       ):







  """simple docstring"""






  super().__init__(pad_token_id=_snake_case				,       **_snake_case     )

  lowerCAmelCase    				= vocab_size
  lowerCAmelCase    				= hidden_size
  lowerCAmelCase    				= num_hidden_layers
  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    				= position_embedding_type
  lowerCAmelCase    				= use_cache





