

from random import randint, random
def      _lowerCAmelCase(	__A   ,       __A   ,       __A   ,       __A = False   ,       __A = False   ,       __A = 5   ,       ):
  UpperCAmelCase					      =  [[-1] * number_of_cells]  # Create a highway without any car
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  max(__A   ,       0			)
  while i < number_of_cells:
    UpperCAmelCase					      =  (
        randint(0   ,       __A			) if random_speed else initial_speed
    )  # Place the cars
    i += (
        randint(1   ,       max_speed * 2			) if random_frequency else frequency
    )  # Arbitrary number, may need tuning
  return highway
def      _lowerCAmelCase(	__A   ,       __A			):
  UpperCAmelCase					      =  0
  UpperCAmelCase					      =  highway_now[car_index + 1 :]
  for cell in range(len(__A			)			):  # May need a better name for this
    if cells[cell] != -1:  # If the cell is not empty then
      return distance  # we have the distance we wanted
    distance += 1
  # Here if the car is near the end of the highway
  return distance + get_distance(__A   ,       -1			)
def      _lowerCAmelCase(	__A   ,       __A   ,       __A			):
  UpperCAmelCase					      =  len(__A			)
  # Beforce calculations, the highway is empty
  UpperCAmelCase					      =  [-1] * number_of_cells

  for car_index in range(__A			):
    if highway_now[car_index] != -1:
      # Add 1 to the current speed of the car and cap the speed
      UpperCAmelCase					      =  min(highway_now[car_index] + 1   ,       __A			)
      # Number of empty cell before the next car
      UpperCAmelCase					      =  get_distance(__A   ,       __A			) - 1
      # We can't have the car causing an accident
      UpperCAmelCase					      =  min(next_highway[car_index]   ,       __A			)
      if random() < probability:
        # Randomly, a driver will slow down
        UpperCAmelCase					      =  max(next_highway[car_index] - 1   ,       0			)
  return next_highway
def      _lowerCAmelCase(	__A   ,       __A   ,       __A   ,       __A			):
  UpperCAmelCase					      =  len(highway[0]			)

  for i in range(__A			):
    UpperCAmelCase					      =  update(highway[i]   ,       __A   ,       __A			)
    UpperCAmelCase					      =  [-1] * number_of_cells

    for car_index in range(__A			):
      UpperCAmelCase					      =  next_speeds_calculated[car_index]
      if speed != -1:
        # Change the position based on the speed (with % to create the loop)
        UpperCAmelCase					      =  (car_index + speed) % number_of_cells
        # Commit the change of position
        UpperCAmelCase					      =  speed
    highway.append(__A			)

  return highway


if __name__ == "__main__":
      import doctest

      doctest.testmod()






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 						__magic_name__    (       _snake_case    ):
 UpperCAmelCase							    =						"""lxmert"""
 UpperCAmelCase							    =						{}


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



