"""simple docstring"""






from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCAmelCase__  :  Optional[Any]						     =	logging.get_logger(__name__)

lowerCAmelCase__  :  Any						     =	{
    'microsoft/beit-base-patch16-224-pt22k': (
        'https://huggingface.co/microsoft/beit-base-patch16-224-pt22k/resolve/main/config.json'
    ),
    # See all BEiT models at https://huggingface.co/models?filter=beit
}
class 				snake_case       ( lowerCAmelCase_				):




					"""simple docstring"""

					snake_case__				    = 'beit'







					def __init__(				self   :	Optional[Any]    ,lowerCamelCase__   :	Any=8_192    ,lowerCamelCase__   :	Tuple=768    ,lowerCamelCase__   :	str=12    ,lowerCamelCase__   :	Optional[int]=12    ,lowerCamelCase__   :	Union[str, Any]=3_072    ,lowerCamelCase__   :	List[str]="gelu"    ,lowerCamelCase__   :	Dict=0.0    ,lowerCamelCase__   :	Tuple=0.0    ,lowerCamelCase__   :	Optional[int]=0.0_2    ,lowerCamelCase__   :	int=1e-12    ,lowerCamelCase__   :	Optional[Any]=224    ,lowerCamelCase__   :	Union[str, Any]=16    ,lowerCamelCase__   :	Dict=3    ,lowerCamelCase__   :	Optional[int]=False    ,lowerCamelCase__   :	Any=False    ,lowerCamelCase__   :	Optional[int]=False    ,lowerCamelCase__   :	Optional[int]=False    ,lowerCamelCase__   :	Optional[int]=0.1    ,lowerCamelCase__   :	int=0.1    ,lowerCamelCase__   :	Dict=True    ,lowerCamelCase__   :	Optional[int]=[3, 5, 7, 11]    ,lowerCamelCase__   :	Tuple=[1, 2, 3, 6]    ,lowerCamelCase__   :	Union[str, Any]=True    ,lowerCamelCase__   :	Optional[int]=0.4    ,lowerCamelCase__   :	List[Any]=256    ,lowerCamelCase__   :	List[str]=1    ,lowerCamelCase__   :	List[str]=False    ,lowerCamelCase__   :	List[Any]=255    ,**lowerCamelCase__   :	List[str]    ,):
									super().__init__(**__lowerCAmelCase			)

									UpperCAmelCase__             =							vocab_size
									UpperCAmelCase__             =							hidden_size
									UpperCAmelCase__             =							num_hidden_layers
									UpperCAmelCase__             =							num_attention_heads
									UpperCAmelCase__             =							intermediate_size
									UpperCAmelCase__             =							hidden_act
									UpperCAmelCase__             =							hidden_dropout_prob
									UpperCAmelCase__             =							attention_probs_dropout_prob
									UpperCAmelCase__             =							initializer_range
									UpperCAmelCase__             =							layer_norm_eps

									UpperCAmelCase__             =							image_size
									UpperCAmelCase__             =							patch_size
									UpperCAmelCase__             =							num_channels
									UpperCAmelCase__             =							use_mask_token
									UpperCAmelCase__             =							use_absolute_position_embeddings
									UpperCAmelCase__             =							use_relative_position_bias
									UpperCAmelCase__             =							use_shared_relative_position_bias
									UpperCAmelCase__             =							layer_scale_init_value
									UpperCAmelCase__             =							drop_path_rate
									UpperCAmelCase__             =							use_mean_pooling
									# decode head attributes (semantic segmentation)
									UpperCAmelCase__             =							out_indices
									UpperCAmelCase__             =							pool_scales
									# auxiliary head attributes (semantic segmentation)
									UpperCAmelCase__             =							use_auxiliary_head
									UpperCAmelCase__             =							auxiliary_loss_weight
									UpperCAmelCase__             =							auxiliary_channels
									UpperCAmelCase__             =							auxiliary_num_convs
									UpperCAmelCase__             =							auxiliary_concat_input
									UpperCAmelCase__             =							semantic_loss_ignore_index






class 				snake_case       ( lowerCAmelCase_				):




					"""simple docstring"""

					snake_case__				    = version.parse("1.11"				)







					@property
					def 		__lowerCAmelCase						(				self   :	Tuple			):
									return OrderedDict(
									    [
									        ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
									    ]			)







					@property
					def 		__lowerCAmelCase						(				self   :	Optional[Any]			):
									return 1e-4




"""simple docstring"""


from __future__ import annotations






def 			__UpperCAmelCase    (	lowercase      ,lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					get_failure_array(lowercase						)

  # 2) Step through text searching for pattern
  _UpperCAmelCase       , _UpperCAmelCase         =					0, 0  # index into text, pattern
  while i < len(lowercase						):
    if pattern[j] == text[i]:
      if j == (len(lowercase						) - 1):
        return True
      j += 1

    # if this is a prefix in our pattern
    # just go back far enough to continue
    elif j > 0:
      _UpperCAmelCase         =					failure[j - 1]
      continue
    i += 1
  return False






def 			__UpperCAmelCase    (	lowercase						):







  """simple docstring"""
  _UpperCAmelCase         =					[0]
  _UpperCAmelCase         =					0
  _UpperCAmelCase         =					1
  while j < len(lowercase						):
    if pattern[i] == pattern[j]:
      i += 1
    elif i > 0:
      _UpperCAmelCase         =					failure[i - 1]
      continue
    j += 1
    failure.append(lowercase						)
  return failure


if __name__ == "__main__":
    # Test 1)
    UpperCAmelCase__     						=  """abc1abc12"""
    UpperCAmelCase__     						=  """alskfjaldsabc1abc1abc12k23adsfabcabc"""
    UpperCAmelCase__     						=  """alskfjaldsk23adsfabcabc"""
    assert kmp(pattern, texta) and not kmp(pattern, texta)

    # Test 2)
    UpperCAmelCase__     						=  """ABABX"""
    UpperCAmelCase__     						=  """ABABZABABYABABX"""
    assert kmp(pattern, text)

    # Test 3)
    UpperCAmelCase__     						=  """AAAB"""
    UpperCAmelCase__     						=  """ABAAAAAB"""
    assert kmp(pattern, text)

    # Test 4)
    UpperCAmelCase__     						=  """abcdabcy"""
    UpperCAmelCase__     						=  """abcxabcdabxabcdabcdabcy"""
    assert kmp(pattern, text)

    # Test 5)
    UpperCAmelCase__     						=  """aabaabaaa"""
    assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]
