






"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase_       			=   logging.get_logger(__name__)

lowerCamelCase_       			=   {
    '''uclanlp/visualbert-vqa''': '''https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json''',
    '''uclanlp/visualbert-vqa-pre''': '''https://huggingface.co/uclanlp/visualbert-vqa-pre/resolve/main/config.json''',
    '''uclanlp/visualbert-vqa-coco-pre''': (
        '''https://huggingface.co/uclanlp/visualbert-vqa-coco-pre/resolve/main/config.json'''
    ),
    '''uclanlp/visualbert-vcr''': '''https://huggingface.co/uclanlp/visualbert-vcr/resolve/main/config.json''',
    '''uclanlp/visualbert-vcr-pre''': '''https://huggingface.co/uclanlp/visualbert-vcr-pre/resolve/main/config.json''',
    '''uclanlp/visualbert-vcr-coco-pre''': (
        '''https://huggingface.co/uclanlp/visualbert-vcr-coco-pre/resolve/main/config.json'''
    ),
    '''uclanlp/visualbert-nlvr2''': '''https://huggingface.co/uclanlp/visualbert-nlvr2/resolve/main/config.json''',
    '''uclanlp/visualbert-nlvr2-pre''': '''https://huggingface.co/uclanlp/visualbert-nlvr2-pre/resolve/main/config.json''',
    '''uclanlp/visualbert-nlvr2-coco-pre''': (
        '''https://huggingface.co/uclanlp/visualbert-nlvr2-coco-pre/resolve/main/config.json'''
    )
    # See all VisualBERT models at https://huggingface.co/models?filter=visual_bert
}







class     UpperCamelCase_ (__A  ):
	__magic_name__			   =       '''visual_bert'''





	def __init__(   self      :				str			,			lowerCAmelCase_      :				str=30_522			,			lowerCAmelCase_      :				Optional[Any]=768			,			lowerCAmelCase_      :				Union[str, Any]=512			,			lowerCAmelCase_      :				Optional[int]=12			,			lowerCAmelCase_      :				Union[str, Any]=12			,			lowerCAmelCase_      :				Dict=3_072			,			lowerCAmelCase_      :				List[str]="gelu"			,			lowerCAmelCase_      :				Union[str, Any]=0.1			,			lowerCAmelCase_      :				str=0.1			,			lowerCAmelCase_      :				Tuple=512			,			lowerCAmelCase_      :				int=2			,			lowerCAmelCase_      :				Union[str, Any]=0.0_2			,			lowerCAmelCase_      :				Union[str, Any]=1e-12			,			lowerCAmelCase_      :				List[str]=False			,			lowerCAmelCase_      :				Dict=True			,			lowerCAmelCase_      :				Tuple=1			,			lowerCAmelCase_      :				List[str]=0			,			lowerCAmelCase_      :				Dict=2			,			**lowerCAmelCase_      :				Dict			,			)		->    List[str]:
				super().__init__(pad_token_id=lowerCAmelCase_			,			bos_token_id=lowerCAmelCase_			,			eos_token_id=lowerCAmelCase_			,			**lowerCAmelCase_		)

				UpperCAmelCase_  :				Union[str, Any]      =      vocab_size
				UpperCAmelCase_  :				str      =      max_position_embeddings
				UpperCAmelCase_  :				Union[str, Any]      =      hidden_size
				UpperCAmelCase_  :				Any      =      visual_embedding_dim
				UpperCAmelCase_  :				List[Any]      =      num_hidden_layers
				UpperCAmelCase_  :				Any      =      num_attention_heads
				UpperCAmelCase_  :				Optional[int]      =      intermediate_size
				UpperCAmelCase_  :				str      =      hidden_act
				UpperCAmelCase_  :				List[str]      =      hidden_dropout_prob
				UpperCAmelCase_  :				Dict      =      attention_probs_dropout_prob
				UpperCAmelCase_  :				Optional[Any]      =      initializer_range
				UpperCAmelCase_  :				int      =      type_vocab_size
				UpperCAmelCase_  :				List[Any]      =      layer_norm_eps
				UpperCAmelCase_  :				Union[str, Any]      =      bypass_transformer
				UpperCAmelCase_  :				Any      =      special_visual_initialize











"""simple docstring"""
from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow


if is_tf_available():
			import numpy as np
			import tensorflow as tf

			from transformers import TFCamembertModel







@require_tf
@require_sentencepiece
@require_tokenizers
class     UpperCamelCase_ (unittest.TestCase  ):





	@slow
	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[Any]		)		->    Optional[Any]:
				UpperCAmelCase_  :				List[Any]      =      TFCamembertModel.from_pretrained("jplu/tf-camembert-base"		)

				UpperCAmelCase_  :				Tuple      =      tf.convert_to_tensor(
				    [[5, 121, 11, 660, 16, 730, 25_543, 110, 83, 6]]			,			dtype=tf.intaa			,			)  # J'aime le camembert !"

				UpperCAmelCase_  :				Any      =      model(lowerCAmelCase_		)["last_hidden_state"]
				UpperCAmelCase_  :				str      =      tf.TensorShape((1, 10, 768)		)
				self.assertEqual(output.shape			,			lowerCAmelCase_		)
				# compare the actual values for a slice.
				UpperCAmelCase_  :				Tuple      =      tf.convert_to_tensor(
				    [[[-0.0_2_5_4, 0.0_2_3_5, 0.1_0_2_7], [0.0_6_0_6, -0.1_8_1_1, -0.0_4_1_8], [-0.1_5_6_1, -0.1_1_2_7, 0.2_6_8_7]]]			,			dtype=tf.floataa			,			)
				# camembert = torch.hub.load('pytorch/fairseq', 'camembert.v0')
				# camembert.eval()
				# expected_slice = roberta.model.forward(input_ids)[0][:, :3, :3].detach()

				self.assertTrue(np.allclose(output[:, :3, :3].numpy()			,			expected_slice.numpy()			,			atol=1e-4		)		)



