

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowercase_   							=  logging.get_logger(__name__)

lowercase_   							=  {
    'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/config.json',
    'bert-large-uncased': 'https://huggingface.co/bert-large-uncased/resolve/main/config.json',
    'bert-base-cased': 'https://huggingface.co/bert-base-cased/resolve/main/config.json',
    'bert-large-cased': 'https://huggingface.co/bert-large-cased/resolve/main/config.json',
    'bert-base-multilingual-uncased': 'https://huggingface.co/bert-base-multilingual-uncased/resolve/main/config.json',
    'bert-base-multilingual-cased': 'https://huggingface.co/bert-base-multilingual-cased/resolve/main/config.json',
    'bert-base-chinese': 'https://huggingface.co/bert-base-chinese/resolve/main/config.json',
    'bert-base-german-cased': 'https://huggingface.co/bert-base-german-cased/resolve/main/config.json',
    'bert-large-uncased-whole-word-masking': (
        'https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/config.json'
    ),
    'bert-large-cased-whole-word-masking': (
        'https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/config.json'
    ),
    'bert-large-uncased-whole-word-masking-finetuned-squad': (
        'https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/config.json'
    ),
    'bert-large-cased-whole-word-masking-finetuned-squad': (
        'https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/config.json'
    ),
    'bert-base-cased-finetuned-mrpc': 'https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/config.json',
    'bert-base-german-dbmdz-cased': 'https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/config.json',
    'bert-base-german-dbmdz-uncased': 'https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/config.json',
    'cl-tohoku/bert-base-japanese': 'https://huggingface.co/cl-tohoku/bert-base-japanese/resolve/main/config.json',
    'cl-tohoku/bert-base-japanese-whole-word-masking': (
        'https://huggingface.co/cl-tohoku/bert-base-japanese-whole-word-masking/resolve/main/config.json'
    ),
    'cl-tohoku/bert-base-japanese-char': (
        'https://huggingface.co/cl-tohoku/bert-base-japanese-char/resolve/main/config.json'
    ),
    'cl-tohoku/bert-base-japanese-char-whole-word-masking': (
        'https://huggingface.co/cl-tohoku/bert-base-japanese-char-whole-word-masking/resolve/main/config.json'
    ),
    'TurkuNLP/bert-base-finnish-cased-v1': (
        'https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/config.json'
    ),
    'TurkuNLP/bert-base-finnish-uncased-v1': (
        'https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/config.json'
    ),
    'wietsedv/bert-base-dutch-cased': 'https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/config.json',
    # See all BERT models at https://huggingface.co/models?filter=bert
}





class 					__lowerCAmelCase	(   SCREAMING_SNAKE_CASE				):
  _a		     =    """bert"""




  def __init__(							self				,  lowerCAmelCase=30_522				,  lowerCAmelCase=768				,  lowerCAmelCase=12				,  lowerCAmelCase=12				,  lowerCAmelCase=3_072				,  lowerCAmelCase="gelu"				,  lowerCAmelCase=0.1				,  lowerCAmelCase=0.1				,  lowerCAmelCase=512				,  lowerCAmelCase=2				,  lowerCAmelCase=0.02				,  lowerCAmelCase=1e-12				,  lowerCAmelCase=0				,  lowerCAmelCase="absolute"				,  lowerCAmelCase=True				,  lowerCAmelCase=None				,  **lowerCAmelCase				,  )    ->					Tuple:
        '''simple docstring'''






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

        _lowercase      			=vocab_size
        _lowercase      			=hidden_size
        _lowercase      			=num_hidden_layers
        _lowercase      			=num_attention_heads
        _lowercase      			=hidden_act
        _lowercase      			=intermediate_size
        _lowercase      			=hidden_dropout_prob
        _lowercase      			=attention_probs_dropout_prob
        _lowercase      			=max_position_embeddings
        _lowercase      			=type_vocab_size
        _lowercase      			=initializer_range
        _lowercase      			=layer_norm_eps
        _lowercase      			=position_embedding_type
        _lowercase      			=use_cache
        _lowercase      			=classifier_dropout





class 					__lowerCAmelCase	(   SCREAMING_SNAKE_CASE				):




  @property
  def     A__	(							self   )    ->					Mapping[str, Mapping[int, str]]:
        '''simple docstring'''






        if self.task == "multiple-choice":
              _lowercase      			={0: 'batch', 1: 'choice', 2: 'sequence'}
        else:
              _lowercase      			={0: 'batch', 1: 'sequence'}
        return OrderedDict(
            [
                ('input_ids', dynamic_axis),
                ('attention_mask', dynamic_axis),
                ('token_type_ids', dynamic_axis),
            ]   )





import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


lowercase_   							=  '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]\n'





class 					__lowerCAmelCase	(   unittest.TestCase     ,     SCREAMING_SNAKE_CASE				):




  def     A__	(							self   )    ->					Union[str, Any]:
        '''simple docstring'''






        _lowercase      			=load_tool('text-question-answering'   )
        self.tool.setup()
        _lowercase      			=load_tool('text-question-answering'				,  remote=lowerCAmelCase   )




  def     A__	(							self   )    ->					Dict:
        '''simple docstring'''






        _lowercase      			=self.tool(lowerCAmelCase				,  'What did Hugging Face do in April 2021?'   )
        self.assertEqual(lowerCAmelCase				,  'launched the BigScience Research Workshop'   )




  def     A__	(							self   )    ->					Optional[Any]:
        '''simple docstring'''






        _lowercase      			=self.remote_tool(lowerCAmelCase				,  'What did Hugging Face do in April 2021?'   )
        self.assertEqual(lowerCAmelCase				,  'launched the BigScience Research Workshop'   )




  def     A__	(							self   )    ->					Any:
        '''simple docstring'''






        _lowercase      			=self.tool(text=lowerCAmelCase				,  question='What did Hugging Face do in April 2021?'   )
        self.assertEqual(lowerCAmelCase				,  'launched the BigScience Research Workshop'   )




  def     A__	(							self   )    ->					Optional[int]:
        '''simple docstring'''






        _lowercase      			=self.remote_tool(text=lowerCAmelCase				,  question='What did Hugging Face do in April 2021?'   )
        self.assertEqual(lowerCAmelCase				,  'launched the BigScience Research Workshop'   )


