


"""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


__SCREAMING_SNAKE_CASE							:    str		=    logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE							:    Any		=    {
    'hustvl/yolos-small': 'https://huggingface.co/hustvl/yolos-small/resolve/main/config.json',
    # See all YOLOS models at https://huggingface.co/models?filter=yolos
}





class      __A     (_UpperCamelCase):





       '''simple docstring'''

       __lowercase:		Tuple							      =    "yolos"



       def __init__(				self							:      Dict		,       UpperCAmelCase_							:      Optional[Any]=768		,       UpperCAmelCase_							:      List[Any]=12		,       UpperCAmelCase_							:      Any=12		,       UpperCAmelCase_							:      List[Any]=3_072		,       UpperCAmelCase_							:      Optional[int]="gelu"		,       UpperCAmelCase_							:      Dict=0.0		,       UpperCAmelCase_							:      Optional[Any]=0.0		,       UpperCAmelCase_							:      Any=0.02		,       UpperCAmelCase_							:      Optional[int]=1E-12		,       UpperCAmelCase_							:      List[Any]=[512, 864]		,       UpperCAmelCase_							:      List[str]=16		,       UpperCAmelCase_							:      str=3		,       UpperCAmelCase_							:      Optional[Any]=True		,       UpperCAmelCase_							:      Optional[Any]=100		,       UpperCAmelCase_							:      List[str]=True		,       UpperCAmelCase_							:      Any=False		,       UpperCAmelCase_							:      List[str]=1		,       UpperCAmelCase_							:      str=5		,       UpperCAmelCase_							:      Optional[Any]=2		,       UpperCAmelCase_							:      Tuple=5		,       UpperCAmelCase_							:      Any=2		,       UpperCAmelCase_							:      Union[str, Any]=0.1		,       **UpperCAmelCase_							:      List[str]		,       )					->List[str]:



              """simple docstring"""



              super().__init__(**__a       )

              snake_case_           =		hidden_size
              snake_case_           =		num_hidden_layers
              snake_case_           =		num_attention_heads
              snake_case_           =		intermediate_size
              snake_case_           =		hidden_act
              snake_case_           =		hidden_dropout_prob
              snake_case_           =		attention_probs_dropout_prob
              snake_case_           =		initializer_range
              snake_case_           =		layer_norm_eps
              snake_case_           =		image_size
              snake_case_           =		patch_size
              snake_case_           =		num_channels
              snake_case_           =		qkv_bias
              snake_case_           =		num_detection_tokens
              snake_case_           =		use_mid_position_embeddings
              snake_case_           =		auxiliary_loss
              # Hungarian matcher
              snake_case_           =		class_cost
              snake_case_           =		bbox_cost
              snake_case_           =		giou_cost
              # Loss coefficients
              snake_case_           =		bbox_loss_coefficient
              snake_case_           =		giou_loss_coefficient
              snake_case_           =		eos_coefficient





class      __A     (_UpperCamelCase):





       '''simple docstring'''

       __lowercase:		List[str]							      =    version.parse("""1.11""")



       @property
       def 		lowerCAmelCase       (				self							:      str       )					->Mapping[str, Mapping[int, str]]:



              """simple docstring"""



              return OrderedDict(
                  [
                      ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
                  ]       )



       @property
       def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->float:



              """simple docstring"""



              return 1E-4



       @property
       def 		lowerCAmelCase       (				self							:      Dict       )					->int:



              """simple docstring"""



              return 12







"""simple docstring"""
from __future__ import annotations

from collections import deque





class      __A     :





							'''simple docstring'''

							def __init__(				self							:      List[Any]		,       UpperCAmelCase_							:      list[str]       )					->List[Any]:



														"""simple docstring"""



														snake_case_           =		[]
														self.adlist.append(
														    {"""value""": """""", """next_states""": [], """fail_state""": 0, """output""": []}       )

														for keyword in keywords:
																					self.add_keyword(UpperCAmelCase_       )
														self.set_fail_transitions()



							def 		lowerCAmelCase       (				self							:      int		,       UpperCAmelCase_							:      int		,       UpperCAmelCase_							:      str       )					->int | None:



														"""simple docstring"""



														for state in self.adlist[current_state]["next_states"]:
																					if char == self.adlist[state]["value"]:
																												return state
														return None



							def 		lowerCAmelCase       (				self							:      int		,       UpperCAmelCase_							:      str       )					->None:



														"""simple docstring"""



														snake_case_           =		0
														for character in keyword:
																					snake_case_           =		self.find_next_state(UpperCAmelCase_		,       UpperCAmelCase_       )
																					if next_state is None:
																												self.adlist.append(
																												    {
																												        """value""": character,
																												        """next_states""": [],
																												        """fail_state""": 0,
																												        """output""": [],
																												    }       )
																												self.adlist[current_state]["next_states"].append(len(self.adlist       ) - 1       )
																												snake_case_           =		len(self.adlist       ) - 1
																					else:
																												snake_case_           =		next_state
														self.adlist[current_state]["output"].append(UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      Optional[Any]       )					->None:



														"""simple docstring"""



														snake_case_           =		deque()
														for node in self.adlist[0]["next_states"]:
																					q.append(UpperCAmelCase_       )
																					snake_case_           =		0
														while q:
																					snake_case_           =		q.popleft()
																					for child in self.adlist[r]["next_states"]:
																												q.append(UpperCAmelCase_       )
																												snake_case_           =		self.adlist[r]["""fail_state"""]
																												while (
																												    self.find_next_state(UpperCAmelCase_		,       self.adlist[child]["""value"""]       ) is None
																												    and state != 0
																												):
																																			snake_case_           =		self.adlist[state]["""fail_state"""]
																												snake_case_           =		self.find_next_state(
																												    UpperCAmelCase_		,       self.adlist[child]["""value"""]       )
																												if self.adlist[child]["fail_state"] is None:
																																			snake_case_           =		0
																												snake_case_           =		(
																												    self.adlist[child]["""output"""]
																												    + self.adlist[self.adlist[child]["""fail_state"""]]["""output"""]
																												)



							def 		lowerCAmelCase       (				self							:      Union[str, Any]		,       UpperCAmelCase_							:      str       )					->dict[str, list[int]]:



														"""simple docstring"""



														snake_case_           =		{}  # returns a dict with keywords and list of its occurrences
														snake_case_           =		0
														for i in range(len(UpperCAmelCase_       )       ):
																					while (
																					    self.find_next_state(UpperCAmelCase_		,       string[i]       ) is None
																					    and current_state != 0
																					):
																												snake_case_           =		self.adlist[current_state]["""fail_state"""]
																					snake_case_           =		self.find_next_state(UpperCAmelCase_		,       string[i]       )
																					if next_state is None:
																												snake_case_           =		0
																					else:
																												snake_case_           =		next_state
																												for key in self.adlist[current_state]["output"]:
																																			if key not in result:
																																										snake_case_           =		[]
																																			result[key].append(i - len(UpperCAmelCase_       ) + 1       )
														return result


if __name__ == "__main__":
				import doctest

				doctest.testmod()



