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


_snake_case      = logging.get_logger(__name__)

_snake_case      = {
    "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json",
}
class       _lowerCAmelCase  (		a_							):

 """simple docstring"""
 SCREAMING_SNAKE_CASE_				:					Optional[Any]       						='''lxmert'''
 SCREAMING_SNAKE_CASE_				:					str       						={}

 def __init__(						self			:			Optional[int]					, SCREAMING_SNAKE_CASE__			:			Optional[int]=3_05_22					, SCREAMING_SNAKE_CASE__			:			List[str]=7_68					, SCREAMING_SNAKE_CASE__			:			List[str]=12					, SCREAMING_SNAKE_CASE__			:			List[Any]=95_00					, SCREAMING_SNAKE_CASE__			:			str=16_00					, SCREAMING_SNAKE_CASE__			:			Union[str, Any]=4_00					, SCREAMING_SNAKE_CASE__			:			int=30_72					, SCREAMING_SNAKE_CASE__			:			str="gelu"					, SCREAMING_SNAKE_CASE__			:			Optional[Any]=0.1					, SCREAMING_SNAKE_CASE__			:			int=0.1					, SCREAMING_SNAKE_CASE__			:			Dict=5_12					, SCREAMING_SNAKE_CASE__			:			Dict=2					, SCREAMING_SNAKE_CASE__			:			Union[str, Any]=0.02					, SCREAMING_SNAKE_CASE__			:			str=1e-12					, SCREAMING_SNAKE_CASE__			:			Optional[int]=9					, SCREAMING_SNAKE_CASE__			:			Dict=5					, SCREAMING_SNAKE_CASE__			:			List[str]=5					, SCREAMING_SNAKE_CASE__			:			Tuple=20_48					, SCREAMING_SNAKE_CASE__			:			Dict=4					, SCREAMING_SNAKE_CASE__			:			Union[str, Any]=6.67					, SCREAMING_SNAKE_CASE__			:			Dict=True					, SCREAMING_SNAKE_CASE__			:			Optional[int]=True					, SCREAMING_SNAKE_CASE__			:			Any=True					, SCREAMING_SNAKE_CASE__			:			Tuple=True					, SCREAMING_SNAKE_CASE__			:			Optional[Any]=True					, SCREAMING_SNAKE_CASE__			:			int=True					, SCREAMING_SNAKE_CASE__			:			Union[str, Any]=True					, **SCREAMING_SNAKE_CASE__			:			int					, ):






      """simple docstring"""



      UpperCamelCase						    =					vocab_size
      UpperCamelCase						    =					hidden_size
      UpperCamelCase						    =					num_attention_heads
      UpperCamelCase						    =					hidden_act
      UpperCamelCase						    =					intermediate_size
      UpperCamelCase						    =					hidden_dropout_prob
      UpperCamelCase						    =					attention_probs_dropout_prob
      UpperCamelCase						    =					max_position_embeddings
      UpperCamelCase						    =					type_vocab_size
      UpperCamelCase						    =					initializer_range
      UpperCamelCase						    =					layer_norm_eps
      UpperCamelCase						    =					num_qa_labels
      UpperCamelCase						    =					num_object_labels
      UpperCamelCase						    =					num_attr_labels
      UpperCamelCase						    =					l_layers
      UpperCamelCase						    =					x_layers
      UpperCamelCase						    =					r_layers
      UpperCamelCase						    =					visual_feat_dim
      UpperCamelCase						    =					visual_pos_dim
      UpperCamelCase						    =					visual_loss_normalizer
      UpperCamelCase						    =					task_matched
      UpperCamelCase						    =					task_mask_lm
      UpperCamelCase						    =					task_obj_predict
      UpperCamelCase						    =					task_qa
      UpperCamelCase						    =					visual_obj_loss
      UpperCamelCase						    =					visual_attr_loss
      UpperCamelCase						    =					visual_feat_loss
      UpperCamelCase						    =					{'vision': r_layers, 'cross_encoder': x_layers, 'language': l_layers}
      super().__init__(**_SCREAMING_SNAKE_CASE   )





'''simple docstring'''



import itertools
from dataclasses import dataclass
from typing import Optional

import pandas as pd
import pyarrow as pa

import datasets
from datasets.table import table_cast



@dataclass
class 				_snake_case					(   datasets.BuilderConfig			):
  SCREAMING_SNAKE_CASE			:       Optional[datasets.Features]				=     None



class 				_snake_case					(   datasets.ArrowBasedBuilder			):
  SCREAMING_SNAKE_CASE			:       Tuple				=     PandasConfig

  def   _SCREAMING_SNAKE_CASE				(				self	):





      '''simple docstring'''

      return datasets.DatasetInfo(features=self.config.features	)

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      if not self.config.data_files:
          raise ValueError(F'At least one data file must be specified, but got data_files={self.config.data_files}'	)
      lowerCAmelCase 						=							dl_manager.download_and_extract(self.config.data_files	)
      if isinstance(_SCREAMING_SNAKE_CASE      , (str, list, tuple)	):
          lowerCAmelCase 						=							data_files
          if isinstance(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):
              lowerCAmelCase 						=							[files]
          # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
          lowerCAmelCase 						=							[dl_manager.iter_files(_SCREAMING_SNAKE_CASE	) for file in files]
          return [datasets.SplitGenerator(name=datasets.Split.TRAIN      , gen_kwargs={'files': files}	)]
      lowerCAmelCase 						=							[]
      for split_name, files in data_files.items():
          if isinstance(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):
              lowerCAmelCase 						=							[files]
          # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
          lowerCAmelCase 						=							[dl_manager.iter_files(_SCREAMING_SNAKE_CASE	) for file in files]
          splits.append(datasets.SplitGenerator(name=_SCREAMING_SNAKE_CASE      , gen_kwargs={'files': files}	)	)
      return splits

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      if self.config.features is not None:
          # more expensive cast to support nested features with keys in a different order
          # allows str <-> int/float or str to Audio for example
          lowerCAmelCase 						=							table_cast(_SCREAMING_SNAKE_CASE      , self.config.features.arrow_schema	)
      return pa_table


  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      for i, file in enumerate(itertools.chain.from_iterable(_SCREAMING_SNAKE_CASE	)	):
          with open(_SCREAMING_SNAKE_CASE      , 'rb'	) as f:
              lowerCAmelCase 						=							pa.Table.from_pandas(pd.read_pickle(_SCREAMING_SNAKE_CASE	)	)
              yield i, self._cast_table(_SCREAMING_SNAKE_CASE	)





