






from __future__ import annotations

from collections import deque


class    __lowercase   :







     '''simple docstring'''




     def __init__(					self							:      Dict			,						UpperCamelCase_							:      list[str]					):


         """simple docstring"""



         __A       =						[]
         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							:      Dict			,						UpperCamelCase_							:      int			,						UpperCamelCase_							:      str					):


         """simple docstring"""



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




     def 		lowerCAmelCase_  (					self							:      Union[str, Any]			,						UpperCamelCase_							:      str					):


         """simple docstring"""



         __A       =						0
         for character in keyword:
             __A       =						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					)
                 __A       =						len(self.adlist					) - 1
             else:
                 __A       =						next_state
         self.adlist[current_state]["output"].append(UpperCamelCase_					)




     def 		lowerCAmelCase_  (					self							:      Optional[Any]					):


         """simple docstring"""



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





     def 		lowerCAmelCase_  (					self							:      int			,						UpperCamelCase_							:      str					):


         """simple docstring"""



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


if __name__ == "__main__":
  import doctest

  doctest.testmod()












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


__a   :							List[Any]						= logging.get_logger(__name__)

# TODO: upload to AWS
__a   :							Union[str, Any]						= {
    "yjernite/retribert-base-uncased": (
        "https://huggingface.co/yjernite/retribert-base-uncased/resolve/main/config.json"
    ),
}


class    __lowercase   (						lowercase_	):







     '''simple docstring'''
     SCREAMING_SNAKE_CASE     =					"retribert"




     def __init__(					self							:      Any			,						UpperCamelCase_							:      int=30_522			,						UpperCamelCase_							:      Optional[int]=768			,						UpperCamelCase_							:      Union[str, Any]=8			,						UpperCamelCase_							:      Tuple=12			,						UpperCamelCase_							:      List[Any]=3_072			,						UpperCamelCase_							:      Tuple="gelu"			,						UpperCamelCase_							:      str=0.1			,						UpperCamelCase_							:      Dict=0.1			,						UpperCamelCase_							:      List[str]=512			,						UpperCamelCase_							:      Optional[int]=2			,						UpperCamelCase_							:      Tuple=0.02			,						UpperCamelCase_							:      List[str]=1e-12			,						UpperCamelCase_							:      Any=True			,						UpperCamelCase_							:      List[Any]=128			,						UpperCamelCase_							:      Union[str, Any]=0			,						**UpperCamelCase_							:      List[str]			,						):


         """simple docstring"""



         super().__init__(pad_token_id=UpperCamelCase_			,						**UpperCamelCase_					)

         __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       =						share_encoders
         __A       =						projection_dim




