code: 
  '''simple docstring'''
  
  from collections import OrderedDict
  from typing import Any, List, Mapping, Optional
  
  from ... import PretrainedConfig, PreTrainedTokenizer
  from ...onnx import OnnxConfig, PatchingSpec
  from ...utils import TensorType, is_torch_available, logging
  
  
  UpperCamelCase_     			=       logging.get_logger(__name__)
  
  UpperCamelCase_     			=       {
      """microsoft/layoutlm-base-uncased""": (
          """https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/config.json"""
      ),
      """microsoft/layoutlm-large-uncased""": (
          """https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/config.json"""
      ),
  }
  
  
  class   a_  (_a    ):
         __lowerCAmelCase    :				Dict    =      """layoutlm"""
  
  
  
  
         def __init__(     self   ,   snake_case_=3_0_5_2_2   ,   snake_case_=7_6_8   ,   snake_case_=1_2   ,   snake_case_=1_2   ,   snake_case_=3_0_7_2   ,   snake_case_="gelu"   ,   snake_case_=0.1   ,   snake_case_=0.1   ,   snake_case_=5_1_2   ,   snake_case_=2   ,   snake_case_=0.02   ,   snake_case_=1E-12   ,   snake_case_=0   ,   snake_case_="absolute"   ,   snake_case_=True   ,   snake_case_=1_0_2_4   ,   **snake_case_   ,   ):
           super().__init__(pad_token_id=snake_case_   ,   **snake_case_  )
           _lowerCAmelCase       :  Tuple   				=					vocab_size
           _lowerCAmelCase       :  int   				=					hidden_size
           _lowerCAmelCase       :  Any   				=					num_hidden_layers
           _lowerCAmelCase       :  str   				=					num_attention_heads
           _lowerCAmelCase       :  int   				=					hidden_act
           _lowerCAmelCase       :  Dict   				=					intermediate_size
           _lowerCAmelCase       :  Tuple   				=					hidden_dropout_prob
           _lowerCAmelCase       :  Union[str, Any]   				=					attention_probs_dropout_prob
           _lowerCAmelCase       :  str   				=					max_position_embeddings
           _lowerCAmelCase       :  Dict   				=					type_vocab_size
           _lowerCAmelCase       :  List[Any]   				=					initializer_range
           _lowerCAmelCase       :  str   				=					layer_norm_eps
           _lowerCAmelCase       :  Dict   				=					position_embedding_type
           _lowerCAmelCase       :  Any   				=					use_cache
           _lowerCAmelCase       :  str   				=					max_ad_position_embeddings
  
  
  
  class   a_  (_a    ):
  
  
  
  
         def __init__(     self   ,   snake_case_   ,   snake_case_ = "default"   ,   snake_case_ = None   ,   ):
           super().__init__(snake_case_   ,   task=snake_case_   ,   patching_specs=snake_case_  )
           _lowerCAmelCase       :  Any   				=					config.max_ad_position_embeddings - 1
  
  
  
  
         @property
         def 							__UpperCamelCase       (     self  ):
           return OrderedDict(
               [
                   ("""input_ids""", {0: """batch""", 1: """sequence"""}),
                   ("""bbox""", {0: """batch""", 1: """sequence"""}),
                   ("""attention_mask""", {0: """batch""", 1: """sequence"""}),
                   ("""token_type_ids""", {0: """batch""", 1: """sequence"""}),
               ]  )
  
  
  
  
  
  
  
         def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_ = -1   ,   snake_case_ = -1   ,   snake_case_ = False   ,   snake_case_ = None   ,   ):
           _lowerCAmelCase       :  Optional[Any]   				=					super().generate_dummy_inputs(
               snake_case_   ,   batch_size=snake_case_   ,   seq_length=snake_case_   ,   is_pair=snake_case_   ,   framework=snake_case_  )
  
           # Generate a dummy bbox
           _lowerCAmelCase       :  List[Any]   				=					[4_8, 8_4, 7_3, 1_2_8]
  
           if not framework == TensorType.PYTORCH:
             raise NotImplementedError("""Exporting LayoutLM to ONNX is currently only supported for PyTorch."""  )
  
           if not is_torch_available():
             raise ValueError("""Cannot generate dummy inputs without PyTorch installed."""  )
           import torch
  
           _lowerCAmelCase				,					_lowerCAmelCase       :  List[str]   				=					input_dict["""input_ids"""].shape
           _lowerCAmelCase       :  Tuple   				=					torch.tensor([*[box] * seq_length]  ).tile(snake_case_   ,   1   ,   1  )
           return input_dict
  
  
  
style_context: 
  '''simple docstring'''
  
  from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
  from numpy import divide, inta, multiply, ravel, sort, zeros_like
  
  
  def 	_UpperCAmelCase				(  _lowerCamelCase						:       str  ,      _lowerCamelCase						:       List[Any]=3		)    ->						Union[str, Any]:
    _lowerCAmelCase       :  str   				=					int(mask / 2		)
    # copy image size
    _lowerCAmelCase       :  Dict   				=					zeros_like(_lowerCamelCase		)
    for i in range(_lowerCamelCase  ,      gray_img.shape[0] - bd		):
      for j in range(_lowerCamelCase  ,      gray_img.shape[1] - bd		):
        # get mask according with mask
        _lowerCAmelCase       :  Union[str, Any]   				=					ravel(gray_img[i - bd : i + bd + 1, j - bd : j + bd + 1]		)
        # calculate mask median
        _lowerCAmelCase       :  str   				=					sort(_lowerCamelCase		)[inta(divide((multiply(_lowerCamelCase  ,      _lowerCamelCase		))  ,      2		) + 1		)]
        _lowerCAmelCase       :  Dict   				=					median
    return median_img
  
  
  if __name__ == "__main__":
       # read original image
       UpperCamelCase_     			=       imread("""../image_data/lena.jpg""")
       # turn image in gray scale value
       UpperCamelCase_     			=       cvtColor(img, COLOR_BGR2GRAY)
  
       # get values with two different mask size
       UpperCamelCase_     			=       median_filter(gray, 3)
       UpperCamelCase_     			=       median_filter(gray, 5)
  
       # show result images
       imshow("""median filter with 3x3 mask""", medianaxa)
       imshow("""median filter with 5x5 mask""", medianaxa)
       waitKey(0)
  
  
  