
import unittest

from transformers.testing_utils import CaptureStdout
from transformers.tools.python_interpreter import evaluate







def     A__   (  lowerCamelCase  )					->		List[str]:
				return x + 2





class     _UpperCamelCase			(   unittest.TestCase					):






			'''simple docstring'''

			def  lowerCAmelCase__		(    self	:    Union[str, Any] ):
							UpperCamelCase_:							List[str]		=  """x = 3"""
							UpperCamelCase_:							Tuple		=  {}
							UpperCamelCase_:							Optional[Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							assert result == 3
							self.assertDictEqual(snake_case_  ,		{"""x""": 3} )

							UpperCamelCase_:							Tuple		=  """x = y"""
							UpperCamelCase_:							int		=  {"""y""": 5}
							UpperCamelCase_:							Optional[Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							# evaluate returns the value of the last assignment.
							assert result == 5
							self.assertDictEqual(snake_case_  ,		{"""x""": 5, """y""": 5} )

			def  lowerCAmelCase__		(    self	:    Union[str, Any] ):
							UpperCamelCase_:							List[str]		=  """y = add_two(x)"""
							UpperCamelCase_:							Optional[Any]		=  {"""x""": 3}
							UpperCamelCase_:							Optional[int]		=  evaluate(snake_case_  ,		{"""add_two""": add_two}  ,		state=snake_case_ )
							assert result == 5
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """y""": 5} )

							# Won't work without the tool
							with CaptureStdout() as out:
											UpperCamelCase_:							List[Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							assert result is None
							assert "tried to execute add_two" in out.out

			def  lowerCAmelCase__		(    self	:    Union[str, Any] ):
							UpperCamelCase_:							Tuple		=  """x = 3"""
							UpperCamelCase_:							int		=  {}
							UpperCamelCase_:							Optional[int]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							assert result == 3
							self.assertDictEqual(snake_case_  ,		{"""x""": 3} )

			def  lowerCAmelCase__		(    self	:    int ):
							UpperCamelCase_:							Union[str, Any]		=  """test_dict = {'x': x, 'y': add_two(x)}"""
							UpperCamelCase_:							str		=  {"""x""": 3}
							UpperCamelCase_:							Optional[int]		=  evaluate(snake_case_  ,		{"""add_two""": add_two}  ,		state=snake_case_ )
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """y""": 5} )
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """test_dict""": {"""x""": 3, """y""": 5}} )

			def  lowerCAmelCase__		(    self	:    Dict ):
							UpperCamelCase_:							Optional[Any]		=  """x = 3\ny = 5"""
							UpperCamelCase_:							List[str]		=  {}
							UpperCamelCase_:							List[Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							# evaluate returns the value of the last assignment.
							assert result == 5
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """y""": 5} )

			def  lowerCAmelCase__		(    self	:    int ):
							UpperCamelCase_:							int		=  """text = f'This is x: {x}.'"""
							UpperCamelCase_:							Union[str, Any]		=  {"""x""": 3}
							UpperCamelCase_:							Union[str, Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							# evaluate returns the value of the last assignment.
							assert result == "This is x: 3."
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """text""": """This is x: 3."""} )

			def  lowerCAmelCase__		(    self	:    Dict ):
							UpperCamelCase_:							Tuple		=  """if x <= 3:\n    y = 2\nelse:\n    y = 5"""
							UpperCamelCase_:							List[Any]		=  {"""x""": 3}
							UpperCamelCase_:							Union[str, Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							# evaluate returns the value of the last assignment.
							assert result == 2
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """y""": 2} )

							UpperCamelCase_:							str		=  {"""x""": 8}
							UpperCamelCase_:							Tuple		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							# evaluate returns the value of the last assignment.
							assert result == 5
							self.assertDictEqual(snake_case_  ,		{"""x""": 8, """y""": 5} )

			def  lowerCAmelCase__		(    self	:    Optional[Any] ):
							UpperCamelCase_:							Any		=  """test_list = [x, add_two(x)]"""
							UpperCamelCase_:							str		=  {"""x""": 3}
							UpperCamelCase_:							Tuple		=  evaluate(snake_case_  ,		{"""add_two""": add_two}  ,		state=snake_case_ )
							self.assertListEqual(snake_case_  ,		[3, 5] )
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """test_list""": [3, 5]} )

			def  lowerCAmelCase__		(    self	:    Optional[int] ):
							UpperCamelCase_:							Optional[Any]		=  """y = x"""
							UpperCamelCase_:							Optional[int]		=  {"""x""": 3}
							UpperCamelCase_:							Union[str, Any]		=  evaluate(snake_case_  ,		{}  ,		state=snake_case_ )
							assert result == 3
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """y""": 3} )

			def  lowerCAmelCase__		(    self	:    Optional[Any] ):
							UpperCamelCase_:							List[str]		=  """test_list = [x, add_two(x)]\ntest_list[1]"""
							UpperCamelCase_:							List[Any]		=  {"""x""": 3}
							UpperCamelCase_:							str		=  evaluate(snake_case_  ,		{"""add_two""": add_two}  ,		state=snake_case_ )
							assert result == 5
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """test_list""": [3, 5]} )

							UpperCamelCase_:							Optional[int]		=  """test_dict = {'x': x, 'y': add_two(x)}\ntest_dict['y']"""
							UpperCamelCase_:							Any		=  {"""x""": 3}
							UpperCamelCase_:							Dict		=  evaluate(snake_case_  ,		{"""add_two""": add_two}  ,		state=snake_case_ )
							assert result == 5
							self.assertDictEqual(snake_case_  ,		{"""x""": 3, """test_dict""": {"""x""": 3, """y""": 5}} )




			def  lowerCAmelCase__		(    self	:    Optional[int] ):
							UpperCamelCase_:							Dict		=  """x = 0\nfor i in range(3):\n    x = i"""
							UpperCamelCase_:							Optional[int]		=  {}
							UpperCamelCase_:							List[Any]		=  evaluate(snake_case_  ,		{"""range""": range}  ,		state=snake_case_ )
							assert result == 2
							self.assertDictEqual(snake_case_  ,		{"""x""": 2, """i""": 2} )








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


lowerCamelCase_  :	Tuple 				=					logging.get_logger(__name__)

lowerCamelCase_  :	str 				=					{
    """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""",
}

class     _UpperCamelCase			(   _A					):






			'''simple docstring'''

			__UpperCamelCase :  Any    =	"""lxmert"""
			__UpperCamelCase :  Optional[Any]    =	{}

			def __init__(    self	:    Dict  ,		snake_case_	:    List[str]=3_0522  ,		snake_case_	:    int=768  ,		snake_case_	:    str=12  ,		snake_case_	:    Tuple=9500  ,		snake_case_	:    Optional[Any]=1600  ,		snake_case_	:    str=400  ,		snake_case_	:    List[str]=3072  ,		snake_case_	:    Dict="gelu"  ,		snake_case_	:    Optional[Any]=0.1  ,		snake_case_	:    int=0.1  ,		snake_case_	:    Optional[int]=512  ,		snake_case_	:    Tuple=2  ,		snake_case_	:    Optional[int]=0.02  ,		snake_case_	:    Union[str, Any]=1e-12  ,		snake_case_	:    Tuple=9  ,		snake_case_	:    Tuple=5  ,		snake_case_	:    Union[str, Any]=5  ,		snake_case_	:    List[str]=2048  ,		snake_case_	:    Any=4  ,		snake_case_	:    int=6.67  ,		snake_case_	:    Dict=True  ,		snake_case_	:    Tuple=True  ,		snake_case_	:    int=True  ,		snake_case_	:    str=True  ,		snake_case_	:    List[Any]=True  ,		snake_case_	:    List[Any]=True  ,		snake_case_	:    List[str]=True  ,		**snake_case_	:    Optional[int]  ,		):
							UpperCamelCase_:							int		=  vocab_size
							UpperCamelCase_:							Tuple		=  hidden_size
							UpperCamelCase_:							Optional[Any]		=  num_attention_heads
							UpperCamelCase_:							List[str]		=  hidden_act
							UpperCamelCase_:							int		=  intermediate_size
							UpperCamelCase_:							Any		=  hidden_dropout_prob
							UpperCamelCase_:							List[Any]		=  attention_probs_dropout_prob
							UpperCamelCase_:							List[str]		=  max_position_embeddings
							UpperCamelCase_:							Optional[Any]		=  type_vocab_size
							UpperCamelCase_:							Optional[Any]		=  initializer_range
							UpperCamelCase_:							str		=  layer_norm_eps
							UpperCamelCase_:							List[str]		=  num_qa_labels
							UpperCamelCase_:							List[str]		=  num_object_labels
							UpperCamelCase_:							Tuple		=  num_attr_labels
							UpperCamelCase_:							List[Any]		=  l_layers
							UpperCamelCase_:							List[Any]		=  x_layers
							UpperCamelCase_:							Any		=  r_layers
							UpperCamelCase_:							str		=  visual_feat_dim
							UpperCamelCase_:							Union[str, Any]		=  visual_pos_dim
							UpperCamelCase_:							str		=  visual_loss_normalizer
							UpperCamelCase_:							Dict		=  task_matched
							UpperCamelCase_:							Tuple		=  task_mask_lm
							UpperCamelCase_:							List[str]		=  task_obj_predict
							UpperCamelCase_:							Any		=  task_qa
							UpperCamelCase_:							Dict		=  visual_obj_loss
							UpperCamelCase_:							Optional[Any]		=  visual_attr_loss
							UpperCamelCase_:							List[Any]		=  visual_feat_loss
							UpperCamelCase_:							Tuple		=  {"""vision""": r_layers, """cross_encoder""": x_layers, """language""": l_layers}
							super().__init__(**snake_case_ )






