
from collections import OrderedDict
from typing import Mapping

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


__magic_name__           =					logging.get_logger(__name__)

__magic_name__           =					{
    '''google/electra-small-generator''': '''https://huggingface.co/google/electra-small-generator/resolve/main/config.json''',
    '''google/electra-base-generator''': '''https://huggingface.co/google/electra-base-generator/resolve/main/config.json''',
    '''google/electra-large-generator''': '''https://huggingface.co/google/electra-large-generator/resolve/main/config.json''',
    '''google/electra-small-discriminator''': (
        '''https://huggingface.co/google/electra-small-discriminator/resolve/main/config.json'''
    ),
    '''google/electra-base-discriminator''': (
        '''https://huggingface.co/google/electra-base-discriminator/resolve/main/config.json'''
    ),
    '''google/electra-large-discriminator''': (
        '''https://huggingface.co/google/electra-large-discriminator/resolve/main/config.json'''
    ),
}




class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase	):
      _A  :						str      		=       'electra'
      def __init__(     self						,		lowerCamelCase=3_05_22						,		lowerCamelCase=1_28						,		lowerCamelCase=2_56						,		lowerCamelCase=12						,		lowerCamelCase=4						,		lowerCamelCase=10_24						,		lowerCamelCase="gelu"						,		lowerCamelCase=0.1						,		lowerCamelCase=0.1						,		lowerCamelCase=5_12						,		lowerCamelCase=2						,		lowerCamelCase=0.0_2						,		lowerCamelCase=1e-12						,		lowerCamelCase="first"						,		lowerCamelCase=True						,		lowerCamelCase="gelu"						,		lowerCamelCase=0.1						,		lowerCamelCase=0						,		lowerCamelCase="absolute"						,		lowerCamelCase=True						,		lowerCamelCase=None						,		**lowerCamelCase						,		):
          super().__init__(pad_token_id=lowerCamelCase						,		**lowerCamelCase	)

          snake_case__  =			vocab_size
          snake_case__  =			embedding_size
          snake_case__  =			hidden_size
          snake_case__  =			num_hidden_layers
          snake_case__  =			num_attention_heads
          snake_case__  =			intermediate_size
          snake_case__  =			hidden_act
          snake_case__  =			hidden_dropout_prob
          snake_case__  =			attention_probs_dropout_prob
          snake_case__  =			max_position_embeddings
          snake_case__  =			type_vocab_size
          snake_case__  =			initializer_range
          snake_case__  =			layer_norm_eps

          snake_case__  =			summary_type
          snake_case__  =			summary_use_proj
          snake_case__  =			summary_activation
          snake_case__  =			summary_last_dropout
          snake_case__  =			position_embedding_type
          snake_case__  =			use_cache
          snake_case__  =			classifier_dropout





class    _SCREAMING_SNAKE_CASE					( __UpperCamelCase	):
      @property
      def A_     (     self	):
          if self.task == "multiple-choice":
              snake_case__  =			{0: "batch", 1: "choice", 2: "sequence"}
          else:
              snake_case__  =			{0: "batch", 1: "sequence"}
          return OrderedDict(
              [
                  ("input_ids", dynamic_axis),
                  ("attention_mask", dynamic_axis),
                  ("token_type_ids", dynamic_axis),
              ]	)





import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
     from PIL import Image




class    _SCREAMING_SNAKE_CASE					( unittest.TestCase    ,   __UpperCamelCase	):
      def A_     (     self	):
          snake_case__  =			load_tool("image-captioning"	)
          self.tool.setup()
          snake_case__  =			load_tool("image-captioning"						,		remote=lowerCamelCase	)
      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.tool(lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)
      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.remote_tool(lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)
      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.tool(image=lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)



      def A_     (     self	):
          snake_case__  =			Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"	)	) / "000000039769.png"	)
          snake_case__  =			self.remote_tool(image=lowerCamelCase	)
          self.assertEqual(lowerCamelCase						,		"two cats sleeping on a couch"	)



