
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 							A__       (    lowerCamelCase    )	->						int:
				UpperCamelCase_:				Union[str, Any]						=    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.'''    )
				UpperCamelCase_:				Optional[int]						=    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.'''    )

				UpperCamelCase_:				Optional[int]						=    components[:-1] + [test_fn.replace(""".py"""  ,     """"""    )]
				UpperCamelCase_:				Dict						=    """.""".join(lowerCamelCase    )

				return test_module_path







def 							A__       (    lowerCamelCase    )	->						List[str]:
				UpperCamelCase_:				Optional[int]						=    get_module_path(lowerCamelCase    )
				UpperCamelCase_:				List[Any]						=    importlib.import_module(lowerCamelCase    )

				return test_module







def 							A__       (    lowerCamelCase    )	->						str:
				UpperCamelCase_:				List[Any]						=    []
				UpperCamelCase_:				int						=    get_test_module(lowerCamelCase    )
				for attr in dir(lowerCamelCase    ):
								if attr.endswith("""ModelTester"""    ):
												tester_classes.append(getattr(lowerCamelCase  ,     lowerCamelCase    )    )

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







def 							A__       (    lowerCamelCase    )	->						Tuple:
				UpperCamelCase_:				Optional[Any]						=    []
				UpperCamelCase_:				List[Any]						=    get_test_module(lowerCamelCase    )
				for attr in dir(lowerCamelCase    ):
								UpperCamelCase_:				int						=    getattr(lowerCamelCase  ,     lowerCamelCase    )
								# (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).
								UpperCamelCase_:				List[str]						=    getattr(lowerCamelCase  ,     """all_model_classes"""  ,     []    )
								if len(lowerCamelCase    ) > 0:
												test_classes.append(lowerCamelCase    )

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







def 							A__       (    lowerCamelCase    )	->						str:
				UpperCamelCase_:				Union[str, Any]						=    get_test_classes(lowerCamelCase    )
				UpperCamelCase_:				Optional[Any]						=    set()
				for test_class in test_classes:
								model_classes.update(test_class.all_model_classes    )

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







def 							A__       (    lowerCamelCase    )	->						int:
				UpperCamelCase_:				Optional[int]						=    test_class()
				if hasattr(lowerCamelCase  ,     """setUp"""    ):
								test.setUp()

				UpperCamelCase_:				Union[str, Any]						=    None
				if hasattr(lowerCamelCase  ,     """model_tester"""    ):
								# `(TF/Flax)ModelTesterMixin` has this attribute default to `None`. Let's skip this case.
								if test.model_tester is not None:
												UpperCamelCase_:				Any						=    test.model_tester.__class__

				return model_tester







def 							A__       (    lowerCamelCase  ,     lowerCamelCase    )	->						List[Any]:
				UpperCamelCase_:				int						=    get_test_classes(lowerCamelCase    )

				UpperCamelCase_:				Optional[int]						=    []
				for test_class in test_classes:
								if model_class in test_class.all_model_classes:
												target_test_classes.append(lowerCamelCase    )

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







def 							A__       (    lowerCamelCase  ,     lowerCamelCase    )	->						Optional[Any]:
				UpperCamelCase_:				Optional[int]						=    get_test_classes_for_model(lowerCamelCase  ,     lowerCamelCase    )

				UpperCamelCase_:				Tuple						=    []
				for test_class in test_classes:
								UpperCamelCase_:				Tuple						=    get_model_tester_from_test_class(lowerCamelCase    )
								if tester_class is not None:
												tester_classes.append(lowerCamelCase    )

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







def 							A__       (    lowerCamelCase    )	->						str:
				UpperCamelCase_:				List[str]						=    get_test_classes(lowerCamelCase    )
				UpperCamelCase_:				Tuple						=    {test_class: get_model_tester_from_test_class(lowerCamelCase    ) for test_class in test_classes}
				return test_tester_mapping







def 							A__       (    lowerCamelCase    )	->						Union[str, Any]:
				UpperCamelCase_:				str						=    get_model_classes(lowerCamelCase    )
				UpperCamelCase_:				Optional[int]						=    {
				    model_class: get_test_classes_for_model(lowerCamelCase  ,     lowerCamelCase    ) for model_class in model_classes
				}
				return model_test_mapping







def 							A__       (    lowerCamelCase    )	->						List[str]:
				UpperCamelCase_:				Union[str, Any]						=    get_model_classes(lowerCamelCase    )
				UpperCamelCase_:				str						=    {
				    model_class: get_tester_classes_for_model(lowerCamelCase  ,     lowerCamelCase    ) for model_class in model_classes
				}
				return model_to_tester_mapping







def 							A__       (    lowerCamelCase    )	->						Optional[int]:
				if isinstance(lowerCamelCase  ,     lowerCamelCase    ):
								return o
				elif isinstance(lowerCamelCase  ,     lowerCamelCase    ):
								return o.__name__
				elif isinstance(lowerCamelCase  ,     (list, tuple)    ):
								return [to_json(lowerCamelCase    ) for x in o]
				elif isinstance(lowerCamelCase  ,     lowerCamelCase    ):
								return {to_json(lowerCamelCase    ): to_json(lowerCamelCase    ) for k, v in o.items()}
				else:
								return o








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


lowerCamelCase_    :			Any    =	logging.get_logger(__name__)

lowerCamelCase_    :			Dict    =	{
    """facebook/dpr-ctx_encoder-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-question_encoder-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-reader-single-nq-base""": (
        """https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json"""
    ),
    """facebook/dpr-ctx_encoder-multiset-base""": (
        """https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json"""
    ),
    """facebook/dpr-question_encoder-multiset-base""": (
        """https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json"""
    ),
    """facebook/dpr-reader-multiset-base""": (
        """https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json"""
    ),
}

class 							_UpperCamelCase					(       _A	):






			'''simple docstring'''

			__UpperCamelCase   :    Any          =			"""dpr"""

			def __init__(							self			:							str    ,						snake_case_			:							Any=3_0522    ,						snake_case_			:							List[str]=768    ,						snake_case_			:							List[str]=12    ,						snake_case_			:							Union[str, Any]=12    ,						snake_case_			:							Tuple=3072    ,						snake_case_			:							Any="gelu"    ,						snake_case_			:							Optional[Any]=0.1    ,						snake_case_			:							str=0.1    ,						snake_case_			:							Dict=512    ,						snake_case_			:							int=2    ,						snake_case_			:							Union[str, Any]=0.02    ,						snake_case_			:							str=1e-12    ,						snake_case_			:							List[str]=0    ,						snake_case_			:							Any="absolute"    ,						snake_case_			:							int = 0    ,						**snake_case_			:							int    ,						):
							super().__init__(pad_token_id=snake_case_    ,						**snake_case_   )

							UpperCamelCase_:				str						=    vocab_size
							UpperCamelCase_:				Optional[int]						=    hidden_size
							UpperCamelCase_:				int						=    num_hidden_layers
							UpperCamelCase_:				Any						=    num_attention_heads
							UpperCamelCase_:				int						=    hidden_act
							UpperCamelCase_:				Optional[Any]						=    intermediate_size
							UpperCamelCase_:				Tuple						=    hidden_dropout_prob
							UpperCamelCase_:				Tuple						=    attention_probs_dropout_prob
							UpperCamelCase_:				str						=    max_position_embeddings
							UpperCamelCase_:				Any						=    type_vocab_size
							UpperCamelCase_:				Tuple						=    initializer_range
							UpperCamelCase_:				List[Any]						=    layer_norm_eps
							UpperCamelCase_:				Tuple						=    projection_dim
							UpperCamelCase_:				Dict						=    position_embedding_type






