

import dataclasses
import json
import warnings
from dataclasses import dataclass, field
from time import time
from typing import List

from ..utils import logging


UpperCamelCase__  :      Union[str, Any]			=    logging.get_logger(__name__)


def 					_UpperCAmelCase       (  _SCREAMING_SNAKE_CASE					:		Optional[int]=None ,   _SCREAMING_SNAKE_CASE					:		Any=None       ):





    """simple docstring"""


    return field(default_factory=lambda: default ,   metadata=_SCREAMING_SNAKE_CASE       )





@dataclass
class       __snake_case  :
  __lowerCAmelCase     :	List[str]						 =  list_field(
      default=[]     , metadata={
          'help': (
              'Model checkpoints to be provided to the AutoModel classes. Leave blank to benchmark the base version'
              ' of all available models'
          )
      }     , )

  __lowerCAmelCase     :	List[int]						 =  list_field(
      default=[8]     , metadata={'help': 'List of batch sizes for which memory and time performance will be evaluated'}       )

  __lowerCAmelCase     :	List[int]						 =  list_field(
      default=[8, 32, 128, 512]     , metadata={'help': 'List of sequence lengths for which memory and time performance will be evaluated'}     , )

  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={'help': 'Whether to benchmark inference of model. Inference can be disabled via --no-inference.'}     , )
  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={'help': 'Whether to run on available cuda devices. Cuda can be disabled via --no-cuda.'}     , )
  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={'help': 'Whether to run on available tpu devices. TPU can be disabled via --no-tpu.'}       )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Use FP16 to accelerate inference.'}       )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Benchmark training of model'}       )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Verbose memory tracing'}       )
  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={'help': 'Whether to perform speed measurements. Speed measurements can be disabled via --no-speed.'}     , )
  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={
          'help': 'Whether to perform memory measurements. Memory measurements can be disabled via --no-memory'
      }     , )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Trace memory line by line'}       )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Save result to a CSV file'}       )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Save all print statements in a log file'}       )
  __lowerCAmelCase     :	bool						 =  field(default=lowerCAmelCase__     , metadata={'help': 'Whether to print environment information'}       )
  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={
          'help': (
              'Whether to use multiprocessing for memory and speed measurement. It is highly recommended to use'
              ' multiprocessing for accurate CPU and GPU memory measurements. This option should only be disabled'
              ' for debugging / testing and on TPU.'
          )
      }     , )
  __lowerCAmelCase     :	str						 =  field(
      default=f"""inference_time_{round(time()       )}.csv"""     , metadata={'help': 'CSV filename used if saving time results to csv.'}     , )
  __lowerCAmelCase     :	str						 =  field(
      default=f"""inference_memory_{round(time()       )}.csv"""     , metadata={'help': 'CSV filename used if saving memory results to csv.'}     , )
  __lowerCAmelCase     :	str						 =  field(
      default=f"""train_time_{round(time()       )}.csv"""     , metadata={'help': 'CSV filename used if saving time results to csv for training.'}     , )
  __lowerCAmelCase     :	str						 =  field(
      default=f"""train_memory_{round(time()       )}.csv"""     , metadata={'help': 'CSV filename used if saving memory results to csv for training.'}     , )
  __lowerCAmelCase     :	str						 =  field(
      default=f"""env_info_{round(time()       )}.csv"""     , metadata={'help': 'CSV filename used if saving environment information.'}     , )
  __lowerCAmelCase     :	str						 =  field(
      default=f"""log_{round(time()       )}.csv"""     , metadata={'help': 'Log filename used if print statements are saved in log.'}     , )
  __lowerCAmelCase     :	int						 =  field(default=3     , metadata={'help': 'Times an experiment will be run.'}       )
  __lowerCAmelCase     :	bool						 =  field(
      default=lowerCAmelCase__     , metadata={
          'help': (
              'Instead of loading the model as defined in `config.architectures` if exists, just load the pretrain'
              ' model weights.'
          )
      }     , )

  def 						lowerCAmelCase__     (					self):
      warnings.warn(
          f"""The class {self.__class__} is deprecated. Hugging Face Benchmarking utils"""
          ' are deprecated in general and it is advised to use external Benchmarking libraries '
          ' to benchmark Transformer models.'						,		_A						,		)

  def 						lowerCAmelCase__     (					self):
      return json.dumps(dataclasses.asdict(self)						,		indent=2)

  @property
  def 						lowerCAmelCase__     (					self):
      if len(self.models) <= 0:
          raise ValueError(
              'Please make sure you provide at least one model name / model identifier, *e.g.* `--models'
              ' bert-base-cased` or `args.models = [\'bert-base-cased\'].')
      return self.models


  @property
  def 						lowerCAmelCase__     (					self):
      if not self.multi_process:
          return False
      elif self.is_tpu:
          logger.info('Multiprocessing is currently not possible on TPU.')
          return False
      else:
          return True





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


UpperCamelCase__  :      str			=    logging.get_logger(__name__)

UpperCamelCase__  :      Optional[int]			=    {
    "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       __snake_case  (    lowerCAmelCase__       ):
  __lowerCAmelCase     :	Optional[int]						 =  'dpr'

  def __init__(					self						,		_A=30522						,		_A=768						,		_A=12						,		_A=12						,		_A=3072						,		_A="gelu"						,		_A=0.1						,		_A=0.1						,		_A=512						,		_A=2						,		_A=0.0_2						,		_A=1E-12						,		_A=0						,		_A="absolute"						,		_A = 0						,		**_A						,		):
      super().__init__(pad_token_id=_A						,		**_A)

      SCREAMING_SNAKE_CASE_									=						vocab_size
      SCREAMING_SNAKE_CASE_									=						hidden_size
      SCREAMING_SNAKE_CASE_									=						num_hidden_layers
      SCREAMING_SNAKE_CASE_									=						num_attention_heads
      SCREAMING_SNAKE_CASE_									=						hidden_act
      SCREAMING_SNAKE_CASE_									=						intermediate_size
      SCREAMING_SNAKE_CASE_									=						hidden_dropout_prob
      SCREAMING_SNAKE_CASE_									=						attention_probs_dropout_prob
      SCREAMING_SNAKE_CASE_									=						max_position_embeddings
      SCREAMING_SNAKE_CASE_									=						type_vocab_size
      SCREAMING_SNAKE_CASE_									=						initializer_range
      SCREAMING_SNAKE_CASE_									=						layer_norm_eps
      SCREAMING_SNAKE_CASE_									=						projection_dim
      SCREAMING_SNAKE_CASE_									=						position_embedding_type


