

from typing import List

import numpy as np






def 					__lowercase      (     _A			)     ->						int:
      SCREAMING_SNAKE_CASE :      Union[str, Any]       =   {key: len(_A			) for key, value in gen_kwargs.items() if isinstance(_A						,    _A			)}
      if len(set(lists_lengths.values()			)			) > 1:
            raise RuntimeError(
                (
                    """Sharding is ambiguous for this dataset: """
                    + """we found several data sources lists of different lengths, and we don't know over which list we should parallelize:\n"""
                    + """\n""".join(F"\t- key {key} has length {length}" for key, length in lists_lengths.items()			)
                    + """\nTo fix this, check the 'gen_kwargs' and make sure to use lists only for data sources, """
                    + """and use tuples otherwise. In the end there should only be one single list, or several lists with the same length."""
                )			)
      SCREAMING_SNAKE_CASE :      int       =   max(lists_lengths.values()						,    default=0			)
      return max(1						,    _A			)






def 					__lowercase      (     _A						,    _A			)     ->						List[range]:
      SCREAMING_SNAKE_CASE :      Any       =   []
      for group_idx in range(_A			):
            SCREAMING_SNAKE_CASE :      Tuple       =   num_shards // max_num_jobs + (group_idx < (num_shards % max_num_jobs))
            if num_shards_to_add == 0:
                  break
            SCREAMING_SNAKE_CASE :      Dict       =   shards_indices_per_group[-1].stop if shards_indices_per_group else 0
            SCREAMING_SNAKE_CASE :      Dict       =   range(_A						,    start + num_shards_to_add			)
            shards_indices_per_group.append(_A			)
      return shards_indices_per_group






def 					__lowercase      (     _A						,    _A			)     ->						List[dict]:
      SCREAMING_SNAKE_CASE :      Any       =   _number_of_shards_in_gen_kwargs(_A			)
      if num_shards == 1:
            return [dict(_A			)]
      else:
            SCREAMING_SNAKE_CASE :      Optional[int]       =   _distribute_shards(num_shards=_A						,    max_num_jobs=_A			)
            return [
                {
                    key: [value[shard_idx] for shard_idx in shard_indices_per_group[group_idx]]
                    if isinstance(_A						,    _A			)
                    else value
                    for key, value in gen_kwargs.items()
                }
                for group_idx in range(len(_A			)			)
            ]






def 					__lowercase      (     _A			)     ->						dict:
      return {
          key: [value for gen_kwargs in gen_kwargs_list for value in gen_kwargs[key]]
          if isinstance(gen_kwargs_list[0][key]						,    _A			)
          else gen_kwargs_list[0][key]
          for key in gen_kwargs_list[0]
      }







def 					__lowercase      (     _A						,    _A			)     ->						dict:
      SCREAMING_SNAKE_CASE :      List[Any]       =   {len(_A			) for value in gen_kwargs.values() if isinstance(_A						,    _A			)}
      SCREAMING_SNAKE_CASE :      Optional[Any]       =   {}
      for size in list_sizes:
            SCREAMING_SNAKE_CASE :      Optional[Any]       =   list(range(_A			)			)
            rng.shuffle(indices_per_size[size]			)
      # Now let's copy the gen_kwargs and shuffle the lists based on their sizes
      SCREAMING_SNAKE_CASE :      Tuple       =   dict(_A			)
      for key, value in shuffled_kwargs.items():
            if isinstance(_A						,    _A			):
                  SCREAMING_SNAKE_CASE :      Dict       =   [value[i] for i in indices_per_size[len(_A			)]]
      return shuffled_kwargs







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


UpperCAmelCase__ :     List[Any]				    =    logging.get_logger(__name__)

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







class        a__       (   UpperCAmelCase       ):







  """simple docstring"""




  UpperCAmelCase__      : List[str]			       ="""lxmert"""
  UpperCAmelCase__      : str			       ={}


  def __init__(			self    : int				,				UpperCAmelCase__    : Dict=3_0_5_2_2				,				UpperCAmelCase__    : int=7_6_8				,				UpperCAmelCase__    : Union[str, Any]=1_2				,				UpperCAmelCase__    : int=9_5_0_0				,				UpperCAmelCase__    : Union[str, Any]=1_6_0_0				,				UpperCAmelCase__    : Optional[Any]=4_0_0				,				UpperCAmelCase__    : List[str]=3_0_7_2				,				UpperCAmelCase__    : List[Any]="gelu"				,				UpperCAmelCase__    : int=0.1				,				UpperCAmelCase__    : Optional[Any]=0.1				,				UpperCAmelCase__    : Union[str, Any]=5_1_2				,				UpperCAmelCase__    : int=2				,				UpperCAmelCase__    : List[str]=0.02				,				UpperCAmelCase__    : str=1e-12				,				UpperCAmelCase__    : int=9				,				UpperCAmelCase__    : Optional[int]=5				,				UpperCAmelCase__    : int=5				,				UpperCAmelCase__    : List[str]=2_0_4_8				,				UpperCAmelCase__    : Tuple=4				,				UpperCAmelCase__    : List[str]=6.67				,				UpperCAmelCase__    : Optional[int]=True				,				UpperCAmelCase__    : Dict=True				,				UpperCAmelCase__    : Optional[Any]=True				,				UpperCAmelCase__    : Optional[int]=True				,				UpperCAmelCase__    : List[Any]=True				,				UpperCAmelCase__    : Dict=True				,				UpperCAmelCase__    : Optional[Any]=True				,				**UpperCAmelCase__    : Tuple				,				)					->Optional[Any]:
        """simple docstring"""







        SCREAMING_SNAKE_CASE :      List[str]       =   vocab_size
        SCREAMING_SNAKE_CASE :      List[Any]       =   hidden_size
        SCREAMING_SNAKE_CASE :      Any       =   num_attention_heads
        SCREAMING_SNAKE_CASE :      str       =   hidden_act
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   intermediate_size
        SCREAMING_SNAKE_CASE :      List[str]       =   hidden_dropout_prob
        SCREAMING_SNAKE_CASE :      str       =   attention_probs_dropout_prob
        SCREAMING_SNAKE_CASE :      Dict       =   max_position_embeddings
        SCREAMING_SNAKE_CASE :      Any       =   type_vocab_size
        SCREAMING_SNAKE_CASE :      Optional[int]       =   initializer_range
        SCREAMING_SNAKE_CASE :      Optional[int]       =   layer_norm_eps
        SCREAMING_SNAKE_CASE :      Dict       =   num_qa_labels
        SCREAMING_SNAKE_CASE :      str       =   num_object_labels
        SCREAMING_SNAKE_CASE :      str       =   num_attr_labels
        SCREAMING_SNAKE_CASE :      List[str]       =   l_layers
        SCREAMING_SNAKE_CASE :      Optional[int]       =   x_layers
        SCREAMING_SNAKE_CASE :      List[str]       =   r_layers
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   visual_feat_dim
        SCREAMING_SNAKE_CASE :      Dict       =   visual_pos_dim
        SCREAMING_SNAKE_CASE :      List[Any]       =   visual_loss_normalizer
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   task_matched
        SCREAMING_SNAKE_CASE :      int       =   task_mask_lm
        SCREAMING_SNAKE_CASE :      int       =   task_obj_predict
        SCREAMING_SNAKE_CASE :      Optional[int]       =   task_qa
        SCREAMING_SNAKE_CASE :      Any       =   visual_obj_loss
        SCREAMING_SNAKE_CASE :      str       =   visual_attr_loss
        SCREAMING_SNAKE_CASE :      Union[str, Any]       =   visual_feat_loss
        SCREAMING_SNAKE_CASE :      List[Any]       =   {"""vision""": r_layers, """cross_encoder""": x_layers, """language""": l_layers}
        super().__init__(**UpperCAmelCase__		)




