





from typing import Any



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,):
   '''simple docstring'''


   _validation(
       _lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,)
   # Creates data structures and fill initial step
   A_     :				dict			      =	{}
   A_     :				dict			      =	{}
   for state in states_space:
      A_     :				List[str]			      =	observations_space[0]
      A_     :				Tuple			      =	(
          initial_probabilities[state] * emission_probabilities[state][observation]
      )
      A_     :				Optional[Any]			      =	None

   # Fills the data structure with the probabilities of
   # different transitions and pointers to previous states
   for o in range(1  ,len(_lowerCamelCase     )     ):
      A_     :				List[str]			      =	observations_space[o]
      A_     :				str			      =	observations_space[o - 1]
      for state in states_space:
         # Calculates the argmax for probability function
         A_     :				List[Any]			      =	""""""
         A_     :				Dict			      =	-1
         for k_state in states_space:
            A_     :				Dict			      =	(
                probabilities[(k_state, prior_observation)]
                * transition_probabilities[k_state][state]
                * emission_probabilities[state][observation]
            )
            if probability > max_probability:
               A_     :				Optional[Any]			      =	probability
               A_     :				Tuple			      =	k_state

            # Update probabilities and pointers dicts
         A_     :				Dict			      =	(
             probabilities[(arg_max, prior_observation)]
             * transition_probabilities[arg_max][state]
             * emission_probabilities[state][observation]
         )

         A_     :				Tuple			      =	arg_max

    # The final observation
   A_     :				Optional[int]			      =	observations_space[len(_lowerCamelCase     ) - 1]

   # argmax for given final observation
   A_     :				List[Any]			      =	""""""
   A_     :				Tuple			      =	-1
   for k_state in states_space:
      A_     :				Optional[int]			      =	probabilities[(k_state, final_observation)]
      if probability > max_probability:
         A_     :				Any			      =	probability
         A_     :				Dict			      =	k_state
   A_     :				Tuple			      =	arg_max

   # Process pointers backwards
   A_     :				Optional[Any]			      =	last_state
   A_     :				List[str]			      =	[]
   for o in range(len(_lowerCamelCase     ) - 1  ,-1  ,-1     ):
      result.append(_lowerCamelCase     )
      A_     :				Optional[int]			      =	pointers[previous, observations_space[o]]
   result.reverse()

   return result



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,):
   '''simple docstring'''


   _validate_not_empty(
       _lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,)
   _validate_lists(_lowerCamelCase  ,_lowerCamelCase     )
   _validate_dicts(
       _lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase     )



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,):
   '''simple docstring'''


   if not all(
       [
           observations_space,
           states_space,
           initial_probabilities,
           transition_probabilities,
           emission_probabilities,
       ]     ):
      raise ValueError("""There's an empty parameter"""     )



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase     ):
   '''simple docstring'''


   _validate_list(_lowerCamelCase  ,"""observations_space"""     )
   _validate_list(_lowerCamelCase  ,"""states_space"""     )



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase     ):
   '''simple docstring'''


   if not isinstance(_object  ,_lowerCamelCase     ):
      A_     :				Optional[int]			      =	f"""{var_name} must be a list"""
      raise ValueError(_lowerCamelCase     )
   else:
      for x in _object:
         if not isinstance(_lowerCamelCase  ,_lowerCamelCase     ):
            A_     :				str			      =	f"""{var_name} must be a list of strings"""
            raise ValueError(_lowerCamelCase     )



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,):
   '''simple docstring'''


   _validate_dict(_lowerCamelCase  ,"""initial_probabilities"""  ,_lowerCamelCase     )
   _validate_nested_dict(_lowerCamelCase  ,"""transition_probabilities"""     )
   _validate_nested_dict(_lowerCamelCase  ,"""emission_probabilities"""     )



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase     ):
   '''simple docstring'''


   _validate_dict(_object  ,_lowerCamelCase  ,_lowerCamelCase     )
   for x in _object.values():
      _validate_dict(_lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase  ,_lowerCamelCase     )



def     _lowerCAmelCase		(  _lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase  ,_lowerCAmelCase = False     ):
   '''simple docstring'''


   if not isinstance(_object  ,_lowerCamelCase     ):
      A_     :				Dict			      =	f"""{var_name} must be a dict"""
      raise ValueError(_lowerCamelCase     )
   if not all(isinstance(_lowerCamelCase  ,_lowerCamelCase     ) for x in _object     ):
      A_     :				Optional[int]			      =	f"""{var_name} all keys must be strings"""
      raise ValueError(_lowerCamelCase     )
   if not all(isinstance(_lowerCamelCase  ,_lowerCamelCase     ) for x in _object.values()     ):
      A_     :				Optional[Any]			      =	"""nested dictionary """ if nested else """"""
      A_     :				Tuple			      =	f"""{var_name} {nested_text}all values must be {value_type.__name__}"""
      raise ValueError(_lowerCamelCase     )


if __name__ == "__main__":
      from doctest import testmod

      testmod()






import re



def     _lowerCAmelCase		(  _lowerCAmelCase     ):
   '''simple docstring'''


   A_     :				Any			      =	re.compile(r"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$"""     )
   if match := re.search(_lowerCAmelCase  ,_lowerCAmelCase     ):
      return match.string == phone
   return False


if __name__ == "__main__":
      print(indian_phone_validator("""+918827897895"""))






