


'''simple docstring'''



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


__UpperCAmelCase    :Union[str, Any]				       =     logging.get_logger(__name__)

__UpperCAmelCase    :Union[str, Any]				       =     {
    "microsoft/trocr-base-handwritten": (
        "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json"
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}



class 			a       (	_a ):


     """simple docstring"""






     SCREAMING_SNAKE_CASE :				int							     =     "trocr"
     SCREAMING_SNAKE_CASE :				Any							     =     ["past_key_values"]
     SCREAMING_SNAKE_CASE :				Optional[Any]							     =     {
         "num_attention_heads": "decoder_attention_heads",
         "hidden_size": "d_model",
         "num_hidden_layers": "decoder_layers",
     }

     def __init__(       self  :	int							,				snake_case  :	List[Any]=5_0265							,				snake_case  :	Union[str, Any]=1024							,				snake_case  :	Any=12							,				snake_case  :	List[str]=16							,				snake_case  :	Union[str, Any]=4096							,				snake_case  :	Optional[int]="gelu"							,				snake_case  :	Dict=512							,				snake_case  :	Tuple=0.1							,				snake_case  :	Optional[int]=0.0							,				snake_case  :	Optional[int]=0.0							,				snake_case  :	int=2							,				snake_case  :	List[Any]=0.02							,				snake_case  :	str=0.0							,				snake_case  :	Tuple=True							,				snake_case  :	str=False							,				snake_case  :	Dict=True							,				snake_case  :	List[Any]=True							,				snake_case  :	Dict=1							,				snake_case  :	List[Any]=0							,				snake_case  :	List[Any]=2							,				**snake_case  :	List[Any]							,				)		->							Any:
          __UpperCAmelCase			:				Optional[int]													=    vocab_size
          __UpperCAmelCase			:				Tuple													=    d_model
          __UpperCAmelCase			:				List[Any]													=    decoder_layers
          __UpperCAmelCase			:				str													=    decoder_attention_heads
          __UpperCAmelCase			:				List[Any]													=    decoder_ffn_dim
          __UpperCAmelCase			:				Union[str, Any]													=    activation_function
          __UpperCAmelCase			:				Union[str, Any]													=    max_position_embeddings
          __UpperCAmelCase			:				List[str]													=    dropout
          __UpperCAmelCase			:				str													=    attention_dropout
          __UpperCAmelCase			:				Optional[Any]													=    activation_dropout
          __UpperCAmelCase			:				List[Any]													=    init_std
          __UpperCAmelCase			:				Union[str, Any]													=    decoder_layerdrop
          __UpperCAmelCase			:				List[Any]													=    use_cache
          __UpperCAmelCase			:				Tuple													=    scale_embedding
          __UpperCAmelCase			:				List[Any]													=    use_learned_position_embeddings
          __UpperCAmelCase			:				Union[str, Any]													=    layernorm_embedding

          super().__init__(
              pad_token_id=snake_case							,				bos_token_id=snake_case							,				eos_token_id=snake_case							,				decoder_start_token_id=snake_case							,				**snake_case							,				)



'''simple docstring'''



import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey



class 			a       :


     """simple docstring"""






     def __init__(       self  :	Union[str, Any]							,				snake_case  :	List[Any]							,				snake_case  :	int							,				snake_case  :	int    )		->							List[Any]:
          if dst_width < 0 or dst_height < 0:
               raise ValueError('''Destination width/height should be > 0'''    )

          __UpperCAmelCase			:				str													=    img
          __UpperCAmelCase			:				List[Any]													=    img.shape[1]
          __UpperCAmelCase			:				Optional[Any]													=    img.shape[0]
          __UpperCAmelCase			:				Dict													=    dst_width
          __UpperCAmelCase			:				List[str]													=    dst_height

          __UpperCAmelCase			:				Union[str, Any]													=    self.src_w / self.dst_w
          __UpperCAmelCase			:				List[str]													=    self.src_h / self.dst_h

          __UpperCAmelCase			:				Optional[int]													=    (
              np.ones((self.dst_h, self.dst_w, 3)							,				np.uinta    ) * 255
          )

     def 				lowerCamelCase__				(       self  :	Any    )		->							str:
          for i in range(self.dst_h    ):
               for j in range(self.dst_w    ):
                    __UpperCAmelCase			:				Any													=    self.img[self.get_y(snake_case    )][self.get_x(snake_case    )]

     def 				lowerCamelCase__				(       self  :	int							,				snake_case  :	int    )		->							int:
          return int(self.ratio_x * x    )






     def 				lowerCamelCase__				(       self  :	Optional[Any]							,				snake_case  :	int    )		->							int:
          return int(self.ratio_y * y    )


if __name__ == "__main__":
      __UpperCAmelCase       ,					__UpperCAmelCase    :int				       =     8_0_0, 6_0_0
      __UpperCAmelCase    :Dict				       =     imread("image_data/lena.jpg", 1)
      __UpperCAmelCase    :int				       =     NearestNeighbour(im, dst_w, dst_h)
      n.process()

      imshow(
          f"""Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}""", n.output
      )
      waitKey(0)
      destroyAllWindows()