


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


__lowerCamelCase        =     logging.get_logger(__name__)

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


class   a__	(						lowerCAmelCase_    ):
       lowerCamelCase__:     Union[str, Any]							    =     """lxmert"""
       lowerCamelCase__:     List[Any]							    =     {}

       def __init__(   self      :     int      ,							lowerCamelCase_      :     Any=3_0_5_2_2      ,							lowerCamelCase_      :     List[str]=7_6_8      ,							lowerCamelCase_      :     List[Any]=1_2      ,							lowerCamelCase_      :     Optional[int]=9_5_0_0      ,							lowerCamelCase_      :     Dict=1_6_0_0      ,							lowerCamelCase_      :     Union[str, Any]=4_0_0      ,							lowerCamelCase_      :     Dict=3_0_7_2      ,							lowerCamelCase_      :     Union[str, Any]="gelu"      ,							lowerCamelCase_      :     List[str]=0.1      ,							lowerCamelCase_      :     Union[str, Any]=0.1      ,							lowerCamelCase_      :     List[str]=5_1_2      ,							lowerCamelCase_      :     Optional[int]=2      ,							lowerCamelCase_      :     Dict=0.0_2      ,							lowerCamelCase_      :     Any=1E-12      ,							lowerCamelCase_      :     Optional[Any]=9      ,							lowerCamelCase_      :     Optional[int]=5      ,							lowerCamelCase_      :     Any=5      ,							lowerCamelCase_      :     Tuple=2_0_4_8      ,							lowerCamelCase_      :     Tuple=4      ,							lowerCamelCase_      :     Optional[int]=6.6_7      ,							lowerCamelCase_      :     Optional[Any]=True      ,							lowerCamelCase_      :     List[Any]=True      ,							lowerCamelCase_      :     Dict=True      ,							lowerCamelCase_      :     Optional[Any]=True      ,							lowerCamelCase_      :     Optional[int]=True      ,							lowerCamelCase_      :     Optional[int]=True      ,							lowerCamelCase_      :     Optional[int]=True      ,							**lowerCamelCase_      :     List[Any]      ,							):
            a_    :     Any										=    vocab_size
            a_    :     int										=    hidden_size
            a_    :     Union[str, Any]										=    num_attention_heads
            a_    :     int										=    hidden_act
            a_    :     Any										=    intermediate_size
            a_    :     Tuple										=    hidden_dropout_prob
            a_    :     Union[str, Any]										=    attention_probs_dropout_prob
            a_    :     Any										=    max_position_embeddings
            a_    :     List[str]										=    type_vocab_size
            a_    :     Union[str, Any]										=    initializer_range
            a_    :     Optional[Any]										=    layer_norm_eps
            a_    :     Dict										=    num_qa_labels
            a_    :     Optional[int]										=    num_object_labels
            a_    :     str										=    num_attr_labels
            a_    :     Any										=    l_layers
            a_    :     Optional[Any]										=    x_layers
            a_    :     Tuple										=    r_layers
            a_    :     Optional[int]										=    visual_feat_dim
            a_    :     List[Any]										=    visual_pos_dim
            a_    :     List[str]										=    visual_loss_normalizer
            a_    :     List[Any]										=    task_matched
            a_    :     Any										=    task_mask_lm
            a_    :     Tuple										=    task_obj_predict
            a_    :     int										=    task_qa
            a_    :     int										=    visual_obj_loss
            a_    :     Any										=    visual_attr_loss
            a_    :     List[Any]										=    visual_feat_loss
            a_    :     str										=    {"""vision""": r_layers, """cross_encoder""": x_layers, """language""": l_layers}
            super().__init__(**lowerCamelCase_    )







import dataclasses
import json
import warnings
from dataclasses import dataclass, field
from time import time
from typing import List

from ..utils import logging


__lowerCamelCase        =     logging.get_logger(__name__)



def  _a			(						__UpperCamelCase=None  ,  __UpperCamelCase=None ):
     return field(default_factory=lambda: default  ,  metadata=__UpperCamelCase )


@dataclass
class   a__	:
       lowerCamelCase__:     List[str]							    =     list_field(
           default=[]						,       metadata={
               """help""": (
                   """Model checkpoints to be provided to the AutoModel classes. Leave blank to benchmark the base version"""
                   """ of all available models"""
               )
           }						,       )

       lowerCamelCase__:     List[int]							    =     list_field(
           default=[8]						,       metadata={"""help""": """List of batch sizes for which memory and time performance will be evaluated"""}    )

       lowerCamelCase__:     List[int]							    =     list_field(
           default=[8, 32, 128, 512]						,       metadata={"""help""": """List of sequence lengths for which memory and time performance will be evaluated"""}						,       )

       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={"""help""": """Whether to benchmark inference of model. Inference can be disabled via --no-inference."""}						,       )
       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={"""help""": """Whether to run on available cuda devices. Cuda can be disabled via --no-cuda."""}						,       )
       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={"""help""": """Whether to run on available tpu devices. TPU can be disabled via --no-tpu."""}    )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Use FP16 to accelerate inference."""}    )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Benchmark training of model"""}    )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Verbose memory tracing"""}    )
       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={"""help""": """Whether to perform speed measurements. Speed measurements can be disabled via --no-speed."""}						,       )
       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={
               """help""": """Whether to perform memory measurements. Memory measurements can be disabled via --no-memory"""
           }						,       )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Trace memory line by line"""}    )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Save result to a CSV file"""}    )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Save all print statements in a log file"""}    )
       lowerCamelCase__:     bool							    =     field(default=lowerCAmelCase_						,       metadata={"""help""": """Whether to print environment information"""}    )
       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={
               """help""": (
                   """Whether to use multiprocessing for memory and speed measurement. It is highly recommended to use"""
                   """ multiprocessing for accurate CPU and GPU memory measurements. This option should only be disabled"""
                   """ for debugging / testing and on TPU."""
               )
           }						,       )
       lowerCamelCase__:     str							    =     field(
           default=F"""inference_time_{round(time()    )}.csv"""						,       metadata={"""help""": """CSV filename used if saving time results to csv."""}						,       )
       lowerCamelCase__:     str							    =     field(
           default=F"""inference_memory_{round(time()    )}.csv"""						,       metadata={"""help""": """CSV filename used if saving memory results to csv."""}						,       )
       lowerCamelCase__:     str							    =     field(
           default=F"""train_time_{round(time()    )}.csv"""						,       metadata={"""help""": """CSV filename used if saving time results to csv for training."""}						,       )
       lowerCamelCase__:     str							    =     field(
           default=F"""train_memory_{round(time()    )}.csv"""						,       metadata={"""help""": """CSV filename used if saving memory results to csv for training."""}						,       )
       lowerCamelCase__:     str							    =     field(
           default=F"""env_info_{round(time()    )}.csv"""						,       metadata={"""help""": """CSV filename used if saving environment information."""}						,       )
       lowerCamelCase__:     str							    =     field(
           default=F"""log_{round(time()    )}.csv"""						,       metadata={"""help""": """Log filename used if print statements are saved in log."""}						,       )
       lowerCamelCase__:     int							    =     field(default=3						,       metadata={"""help""": """Times an experiment will be run."""}    )
       lowerCamelCase__:     bool							    =     field(
           default=lowerCAmelCase_						,       metadata={
               """help""": (
                   """Instead of loading the model as defined in `config.architectures` if exists, just load the pretrain"""
                   """ model weights."""
               )
           }						,       )

       def 						UpperCAmelCase(   self      :     Any    ):
            warnings.warn(
                F'''The class {self.__class__} is deprecated. Hugging Face Benchmarking utils'''
                """ are deprecated in general and it is advised to use external Benchmarking libraries """
                """ to benchmark Transformer models."""      ,							lowerCamelCase_      ,							)

       def 						UpperCAmelCase(   self      :     Union[str, Any]    ):
            return json.dumps(dataclasses.asdict(self    )      ,							indent=2    )

       @property
       def 						UpperCAmelCase(   self      :     List[str]    ):
            if len(self.models    ) <= 0:
                 raise ValueError(
                     """Please make sure you provide at least one model name / model identifier, *e.g.* `--models"""
                     """ bert-base-cased` or `args.models = ['bert-base-cased']."""    )
            return self.models

       @property
       def 						UpperCAmelCase(   self      :     Union[str, Any]    ):
            if not self.multi_process:
                 return False
            elif self.is_tpu:
                 logger.info("""Multiprocessing is currently not possible on TPU."""    )
                 return False
            else:
                 return True



