
from __future__ import annotations




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




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

				__lowerCamelCase    					=	(not i < 0) and (not j < 0)  # Check lower bounds
				__lowerCamelCase    					=	(i < size) and (j < size)  # Check upper bounds

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

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

												__lowerCamelCase    					=	0
												return False
				return False


if __name__ == "__main__":
					import doctest

					doctest.testmod()





from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
					if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")):
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from ...utils.dummy_torch_and_transformers_objects import UnCLIPImageVariationPipeline, UnCLIPPipeline
else:
					from .pipeline_unclip import UnCLIPPipeline
					from .pipeline_unclip_image_variation import UnCLIPImageVariationPipeline
					from .text_proj import UnCLIPTextProjModel



