






'''simple docstring'''






from __future__ import annotations

from collections import deque




class a_    :







   def __init__(self					,   __a)			->      Optional[Any]:
      """simple docstring"""






      __snake_case				:      list[dict]     							= []
      self.adlist.append(
          {'value': '', 'next_states': [], 'fail_state': 0, 'output': []})

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







   def     SCREAMING_SNAKE_CASE__					(self					,   __a					,   __a)			->      int | None:
      """simple docstring"""






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







   def     SCREAMING_SNAKE_CASE__					(self					,   __a)			->      None:
      """simple docstring"""






      __snake_case				:      Dict     							= 0
      for character in keyword:
         __snake_case				:      Optional[Any]     							= self.find_next_state(__a					,   __a)
         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				:      List[Any]     							= len(self.adlist) - 1
         else:
            __snake_case				:      Union[str, Any]     							= next_state
      self.adlist[current_state]["output"].append(__a)







   def     SCREAMING_SNAKE_CASE__					(self)			->      None:
      """simple docstring"""






      __snake_case				:      deque     							= deque()
      for node in self.adlist[0]["next_states"]:
         q.append(__a)
         __snake_case				:      int     							= 0
      while q:
         __snake_case				:      List[Any]     							= q.popleft()
         for child in self.adlist[r]["next_states"]:
            q.append(__a)
            __snake_case				:      List[Any]     							= self.adlist[r]['fail_state']
            while (
                self.find_next_state(__a					,   self.adlist[child]['value']) is None
                and state != 0
            ):
               __snake_case				:      int     							= self.adlist[state]['fail_state']
            __snake_case				:      Dict     							= self.find_next_state(
                __a					,   self.adlist[child]['value'])
            if self.adlist[child]["fail_state"] is None:
               __snake_case				:      Optional[Any]     							= 0
            __snake_case				:      List[Any]     							= (
                self.adlist[child]['output']
                + self.adlist[self.adlist[child]['fail_state']]['output']
            )







   def     SCREAMING_SNAKE_CASE__					(self					,   __a)			->      dict[str, list[int]]:
      """simple docstring"""






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


if __name__ == "__main__":
      import doctest

      doctest.testmod()







'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__A    	=   {
    '''configuration_biogpt''': ['''BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BioGptConfig'''],
    '''tokenization_biogpt''': ['''BioGptTokenizer'''],
}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __A    	=   [
          '''BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST''',
          '''BioGptForCausalLM''',
          '''BioGptForTokenClassification''',
          '''BioGptForSequenceClassification''',
          '''BioGptModel''',
          '''BioGptPreTrainedModel''',
      ]


if TYPE_CHECKING:
      from .configuration_biogpt import BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, BioGptConfig
      from .tokenization_biogpt import BioGptTokenizer

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_biogpt import (
                BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
                BioGptForCausalLM,
                BioGptForSequenceClassification,
                BioGptForTokenClassification,
                BioGptModel,
                BioGptPreTrainedModel,
            )


else:
      import sys

      __A    	=   _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)