

def        __lowercase   (  _A    ,     _A    ,     _A    ,     _A      )  ->    int:
      return len_board * len_board_column * row + column






def        __lowercase   (  _A    ,     _A    ,     _A    ,     _A    ,     _A    ,     _A    ,     )  ->    bool:

      if board[row][column] != word[word_index]:
            return False

      if word_index == len(_A      ) - 1:
            return True

      SCREAMING_SNAKE_CASE			:   Union[str, Any]	  = [(0, 1), (0, -1), (-1, 0), (1, 0)]
      SCREAMING_SNAKE_CASE			:   Optional[Any]	  = len(_A      )
      SCREAMING_SNAKE_CASE			:   Optional[Any]	  = len(board[0]      )
      for direction in traverts_directions:
            SCREAMING_SNAKE_CASE			:   Optional[int]	  = row + direction[0]
            SCREAMING_SNAKE_CASE			:   List[str]	  = column + direction[1]
            if not (0 <= next_i < len_board and 0 <= next_j < len_board_column):
                  continue

            SCREAMING_SNAKE_CASE			:   Optional[Any]	  = get_point_key(_A    ,     _A    ,     _A    ,     _A      )
            if key in visited_points_set:
                  continue

            visited_points_set.add(_A      )
            if exits_word(_A    ,     _A    ,     _A    ,     _A    ,     word_index + 1    ,     _A      ):
                  return True

            visited_points_set.remove(_A      )

      return False






def        __lowercase   (  _A    ,     _A      )  ->    bool:
      SCREAMING_SNAKE_CASE			:   Optional[int]	  = (
          """The board should be a non empty matrix of single chars strings."""
      )

      SCREAMING_SNAKE_CASE			:   List[str]	  = len(_A      )
      if not isinstance(_A    ,     _A      ) or len(_A      ) == 0:
            raise ValueError(_A      )

      for row in board:
            if not isinstance(_A    ,     _A      ) or len(_A      ) == 0:
                  raise ValueError(_A      )

            for item in row:
                  if not isinstance(_A    ,     _A      ) or len(_A      ) != 1:
                        raise ValueError(_A      )

    # Validate word
      if not isinstance(_A    ,     _A      ) or len(_A      ) == 0:
            raise ValueError(
                """The word parameter should be a string of length greater than 0."""      )

      SCREAMING_SNAKE_CASE			:   str	  = len(board[0]      )
      for i in range(_A      ):
            for j in range(_A      ):
                  if exits_word(
                      _A    ,     _A    ,     _A    ,     _A    ,     0    ,     {get_point_key(_A    ,     _A    ,     _A    ,     _A      )}      ):
                        return True

      return False


if __name__ == "__main__":
  import doctest

  doctest.testmod()







from typing import TYPE_CHECKING

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


UpperCAmelCase__			:  Dict					     =     {"""configuration_hubert""": ["""HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """HubertConfig"""]}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  Union[str, Any]					     =     [
      """HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """HubertForCTC""",
      """HubertForSequenceClassification""",
      """HubertModel""",
      """HubertPreTrainedModel""",
  ]


try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  List[Any]					     =     [
      """TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """TFHubertForCTC""",
      """TFHubertModel""",
      """TFHubertPreTrainedModel""",
  ]

if TYPE_CHECKING:
  from .configuration_hubert import HUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, HubertConfig

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_hubert import (
        HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        HubertForCTC,
        HubertForSequenceClassification,
        HubertModel,
        HubertPreTrainedModel,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_hubert import (
        TF_HUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFHubertForCTC,
        TFHubertModel,
        TFHubertPreTrainedModel,
    )


else:
  import sys

  UpperCAmelCase__			:  str					     =     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




