



from collections import OrderedDict
from typing import Mapping

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


A__     				=	logging.get_logger(__name__)

A__     				=	{
    """mnaylor/mega-base-wikitext""": """https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json""",
}





class  __lowerCAmelCase			(					lowerCamelCase__	):
				__lowerCamelCase			=    '''mega'''




				def __init__(							self						,    _snake_case=30522						,    _snake_case=128						,    _snake_case=4						,    _snake_case=256						,    _snake_case=16						,    _snake_case=True						,    _snake_case=64						,    _snake_case=False						,    _snake_case=-1						,    _snake_case=None						,    _snake_case=True						,    _snake_case="scalenorm"						,    _snake_case=True						,    _snake_case="silu"						,    _snake_case="softmax"						,    _snake_case=0.1						,    _snake_case=0.1						,    _snake_case=0.1						,    _snake_case=False						,    _snake_case=True						,    _snake_case=256						,    _snake_case=True						,    _snake_case=0.1						,    _snake_case=2048						,    _snake_case=False						,    _snake_case=2						,    _snake_case=0.02						,    _snake_case=0.2						,    _snake_case=0.02						,    _snake_case=1.0						,    _snake_case=1						,    _snake_case=0						,    _snake_case=2						,    _snake_case="rotary"						,    _snake_case=None						,    _snake_case=True						,    _snake_case=True						,    **_snake_case						,    ):



									"""simple docstring"""





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

									_lowerCAmelCase      =   vocab_size
									_lowerCAmelCase      =   hidden_size
									_lowerCAmelCase      =   num_hidden_layers
									_lowerCAmelCase      =   activation
									_lowerCAmelCase      =   attention_activation
									_lowerCAmelCase      =   intermediate_size
									_lowerCAmelCase      =   ema_projection_size
									_lowerCAmelCase      =   bidirectional
									_lowerCAmelCase      =   shared_representation_size
									_lowerCAmelCase      =   use_chunking
									_lowerCAmelCase      =   chunk_size
									_lowerCAmelCase      =   truncation
									_lowerCAmelCase      =   normalize_before_mega
									_lowerCAmelCase      =   normalization_type
									_lowerCAmelCase      =   norm_affine
									_lowerCAmelCase      =   dropout_prob
									_lowerCAmelCase      =   hidden_dropout_prob
									_lowerCAmelCase      =   attention_probs_dropout_prob
									_lowerCAmelCase      =   use_feature_dropout
									_lowerCAmelCase      =   use_normalized_ffn
									_lowerCAmelCase      =   nffn_hidden_size
									_lowerCAmelCase      =   normalize_before_ffn
									_lowerCAmelCase      =   nffn_activation_dropout_prob
									_lowerCAmelCase      =   max_positions
									_lowerCAmelCase      =   add_token_type_embeddings
									_lowerCAmelCase      =   type_vocab_size
									_lowerCAmelCase      =   initializer_range
									_lowerCAmelCase      =   ema_delta_alpha_range
									_lowerCAmelCase      =   ema_beta_range
									_lowerCAmelCase      =   ema_gamma_omega_range
									_lowerCAmelCase      =   relative_positional_bias
									_lowerCAmelCase      =   use_cache
									_lowerCAmelCase      =   classifier_dropout
									_lowerCAmelCase      =   add_lm_hidden_dense_layer
									_lowerCAmelCase      =   1  # not used but required by Hugging Face





class  __lowerCAmelCase			(					lowerCamelCase__	):




				@property
				def 							snake_case       (							self		):



									"""simple docstring"""





									if self.task == "multiple-choice":
														_lowerCAmelCase      =   {0: """batch""", 1: """choice""", 2: """sequence"""}
									else:
														_lowerCAmelCase      =   {0: """batch""", 1: """sequence"""}
									return OrderedDict(
									    [
									        ("""input_ids""", dynamic_axis),
									        ("""attention_mask""", 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  __lowerCAmelCase			(					unittest.TestCase	,						lowerCamelCase__	):




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   load_tool("""image-question-answering"""		)
									self.tool.setup()
									_lowerCAmelCase      =   load_tool("""image-question-answering"""						,    remote=_snake_case		)




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
									_lowerCAmelCase      =   self.tool(_snake_case						,    """How many cats are sleeping on the couch?"""		)
									self.assertEqual(_snake_case						,    """2"""		)




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
									_lowerCAmelCase      =   self.remote_tool(_snake_case						,    """How many cats are sleeping on the couch?"""		)
									self.assertEqual(_snake_case						,    """2"""		)




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
									_lowerCAmelCase      =   self.tool(image=_snake_case						,    question="""How many cats are sleeping on the couch?"""		)
									self.assertEqual(_snake_case						,    """2"""		)




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""		)		) / """000000039769.png"""		)
									_lowerCAmelCase      =   self.remote_tool(image=_snake_case						,    question="""How many cats are sleeping on the couch?"""		)
									self.assertEqual(_snake_case						,    """2"""		)



