





from typing import TYPE_CHECKING

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


_UpperCAmelCase             =							{'configuration_glpn': ['GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GLPNConfig']}

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _UpperCAmelCase             =							['GLPNFeatureExtractor']
      _UpperCAmelCase             =							['GLPNImageProcessor']

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      _UpperCAmelCase             =							[
          'GLPN_PRETRAINED_MODEL_ARCHIVE_LIST',
          'GLPNForDepthEstimation',
          'GLPNLayer',
          'GLPNModel',
          'GLPNPreTrainedModel',
      ]


if TYPE_CHECKING:
      from .configuration_glpn import GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP, GLPNConfig

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_glpn import GLPNFeatureExtractor
            from .image_processing_glpn import GLPNImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_glpn import (
                GLPN_PRETRAINED_MODEL_ARCHIVE_LIST,
                GLPNForDepthEstimation,
                GLPNLayer,
                GLPNModel,
                GLPNPreTrainedModel,
            )


else:
      import sys

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






from __future__ import annotations






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[list[int]]   )      ->   bool:
 __lowerCAmelCase					:	Tuple      =       len(SCREAMING_SNAKE_CASE   )
 # We need to create solution object to save path.
 __lowerCAmelCase					:	str      =       [[0 for _ in range(SCREAMING_SNAKE_CASE   )] for _ in range(SCREAMING_SNAKE_CASE   )]
 __lowerCAmelCase					:	str      =       run_maze(SCREAMING_SNAKE_CASE   ,   0   ,   0   ,   SCREAMING_SNAKE_CASE   )
 if solved:
  print("""\n""".join(str(SCREAMING_SNAKE_CASE   ) for row in solutions   )   )
 else:
  print("""No solution exists!"""   )
 return solved






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[list[int]]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[list[int]]   )      ->   bool:
 __lowerCAmelCase					:	List[str]      =       len(SCREAMING_SNAKE_CASE   )
 # Final check point.
 if i == j == (size - 1):
  __lowerCAmelCase					:	str      =       1
  return True

 __lowerCAmelCase					:	Optional[Any]      =       (not i < 0) and (not j < 0)  # Check lower bounds
 __lowerCAmelCase					:	Optional[Any]      =       (i < size) and (j < size)  # Check upper bounds

 if lower_flag and upper_flag:
  # check for already visited and block points.
  __lowerCAmelCase					:	int      =       (not solutions[i][j]) and (not maze[i][j])
  if block_flag:
   # check visited
   __lowerCAmelCase					:	Tuple      =       1

   # check for directions
   if (
       run_maze(SCREAMING_SNAKE_CASE   ,   i + 1   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )
       or run_maze(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   j + 1   ,   SCREAMING_SNAKE_CASE   )
       or run_maze(SCREAMING_SNAKE_CASE   ,   i - 1   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )
       or run_maze(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   j - 1   ,   SCREAMING_SNAKE_CASE   )
   ):
    return True

   __lowerCAmelCase					:	Tuple      =       0
   return False
 return False


if __name__ == "__main__":
      import doctest

      doctest.testmod()