code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  from typing import SupportsIndex
  
  import numpy as np
  from scipy.ndimage import convolve
  
  
  
  
  
  
  def 	UpperCAmelCase__(							_SCREAMING_SNAKE_CASE				:   np.ndarray,_SCREAMING_SNAKE_CASE				:   np.ndarray,_SCREAMING_SNAKE_CASE				:   np.ndarray   ):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			__A=  np.stack((horizontal_flow, vertical_flow),2   )
  
  			# Create a grid of all pixel coordinates and subtract the flow to get the
  			# target pixels coordinates
  			__A=  np.stack(
  			    np.meshgrid(np.arange(0,image.shape[1]   ),np.arange(0,image.shape[0]   )   ),2   )
  			__A=  np.round(grid - flow   ).astype(np.intaa   )
  
  			# Find the locations outside of the original image
  			__A=  (grid < 0) | (grid >= np.array([image.shape[1], image.shape[0]]   ))
  			__A=  0
  
  			__A=  image[grid[:, :, 1], grid[:, :, 0]]
  
  			# Set pixels at invalid locations to 0
  			__A=  0
  
  			return warped
  
  
  
  
  
  
  def 	UpperCAmelCase__(							_SCREAMING_SNAKE_CASE				:   np.ndarray,_SCREAMING_SNAKE_CASE				:   np.ndarray,_SCREAMING_SNAKE_CASE				:   SupportsIndex,_SCREAMING_SNAKE_CASE				:   float | None = None,):
  
  
  
  
  
  
  			"""simple docstring"""
  
  
  
  
  			if alpha is None:
  						__A=  0.1
  
  			# Initialize flow
  			__A=  np.zeros_like(_SCREAMING_SNAKE_CASE   )
  			__A=  np.zeros_like(_SCREAMING_SNAKE_CASE   )
  
  			# Prepare kernels for the calculation of the derivatives and the average velocity
  			__A=  np.array([[-1, 1], [-1, 1]]   ) * 0.25
  			__A=  np.array([[-1, -1], [1, 1]]   ) * 0.25
  			__A=  np.array([[1, 1], [1, 1]]   ) * 0.25
  			__A=  np.array(
  			    [[1 / 12, 1 / 6, 1 / 12], [1 / 6, 0, 1 / 6], [1 / 12, 1 / 6, 1 / 12]]   )
  
  			# Iteratively refine the flow
  			for _ in range(_SCREAMING_SNAKE_CASE   ):
  						__A=  warp(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						__A=  convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   ) + convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						__A=  convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   ) + convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						__A=  convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   ) + convolve(_SCREAMING_SNAKE_CASE,-kernel_t   )
  
  						__A=  convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  						__A=  convolve(_SCREAMING_SNAKE_CASE,_SCREAMING_SNAKE_CASE   )
  
  						# This updates the flow as proposed in the paper (Step 12)
  						__A=  (
  						    derivative_x * avg_horizontal_velocity
  						    + derivative_y * avg_vertical_velocity
  						    + derivative_t
  						)
  						__A=  update / (alpha**2 + derivative_x**2 + derivative_y**2)
  
  						__A=  avg_horizontal_velocity - derivative_x * update
  						__A=  avg_vertical_velocity - derivative_y * update
  
  			return horizontal_flow, vertical_flow
  
  
  if __name__ == "__main__":
  					import doctest
  
  					doctest.testmod()
  
  
  
  
style_context: 
  
  
  '''simple docstring'''
  
  
  
  
  
  from collections import OrderedDict
  from typing import Mapping
  
  from ...configuration_utils import PretrainedConfig
  from ...onnx import OnnxConfig
  from ...utils import logging
  
  
  UpperCAmelCase__      =							logging.get_logger(__name__)
  
  UpperCAmelCase__      =							{
      '''google/mobilebert-uncased''': '''https://huggingface.co/google/mobilebert-uncased/resolve/main/config.json'''
  }
  class 	a__				(				a_      ):
  
  
  
  
  
  			'''simple docstring'''
  
  			A	:							int							= MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
  			A	:							Optional[int]							= '''mobilebert'''
  			def __init__(     self       : Optional[int] ,						lowerCAmelCase_       : str=30_522 ,						lowerCAmelCase_       : List[Any]=512 ,						lowerCAmelCase_       : Optional[int]=24 ,						lowerCAmelCase_       : str=4 ,						lowerCAmelCase_       : List[str]=512 ,						lowerCAmelCase_       : List[str]="relu" ,						lowerCAmelCase_       : Dict=0.0 ,						lowerCAmelCase_       : List[Any]=0.1 ,						lowerCAmelCase_       : Optional[Any]=512 ,						lowerCAmelCase_       : str=2 ,						lowerCAmelCase_       : Dict=0.02 ,						lowerCAmelCase_       : Any=1E-12 ,						lowerCAmelCase_       : List[Any]=0 ,						lowerCAmelCase_       : Union[str, Any]=128 ,						lowerCAmelCase_       : Any=True ,						lowerCAmelCase_       : Optional[Any]=True ,						lowerCAmelCase_       : List[Any]=128 ,						lowerCAmelCase_       : Dict=False ,						lowerCAmelCase_       : Tuple=True ,						lowerCAmelCase_       : Any=4 ,						lowerCAmelCase_       : Optional[Any]="no_norm" ,						lowerCAmelCase_       : Optional[Any]=True ,						lowerCAmelCase_       : Union[str, Any]=None ,						**lowerCAmelCase_       : Union[str, Any] ,						)			->		List[Any]:
  						super().__init__(pad_token_id=lowerCAmelCase_ ,						**lowerCAmelCase_  )
  
  						__A=  vocab_size
  						__A=  hidden_size
  						__A=  num_hidden_layers
  						__A=  num_attention_heads
  						__A=  hidden_act
  						__A=  intermediate_size
  						__A=  hidden_dropout_prob
  						__A=  attention_probs_dropout_prob
  						__A=  max_position_embeddings
  						__A=  type_vocab_size
  						__A=  initializer_range
  						__A=  layer_norm_eps
  						__A=  embedding_size
  						__A=  trigram_input
  						__A=  use_bottleneck
  						__A=  intra_bottleneck_size
  						__A=  use_bottleneck_attention
  						__A=  key_query_shared_bottleneck
  						__A=  num_feedforward_networks
  						__A=  normalization_type
  						__A=  classifier_activation
  
  						if self.use_bottleneck:
  									__A=  intra_bottleneck_size
  						else:
  									__A=  hidden_size
  
  						__A=  classifier_dropout
  
  
  class 	a__				(				a_      ):
  
  
  
  
  
  			'''simple docstring'''
  
  			@property
  			def 				lowerCAmelCase    (     self       : List[str]  )			->		Mapping[str, Mapping[int, str]]:
  						if self.task == "multiple-choice":
  									__A=  {0: 'batch', 1: 'choice', 2: 'sequence'}
  						else:
  									__A=  {0: 'batch', 1: 'sequence'}
  						return OrderedDict(
  						    [
  						        ('input_ids', dynamic_axis),
  						        ('attention_mask', dynamic_axis),
  						        ('token_type_ids', dynamic_axis),
  						    ]  )
  
  
  
  