






'''simple docstring'''




from heapq import heappop, heappush

import numpy as np

def 						__UpperCAmelCase							(			__magic_name__  ,__magic_name__  ,__magic_name__  ,__magic_name__  ,)->     List[Any]:



			"""simple docstring"""



			snake_case_					:       int =							grid.shape
			snake_case_					:       Optional[int] =							[-1, 1, 0, 0]
			snake_case_					:       Any =							[0, 0, -1, 1]
			if allow_diagonal:
						dx += [-1, -1, 1, 1]
						dy += [-1, 1, -1, 1]

			snake_case_					:       str =							[(0, source)], set()
			snake_case_					:       str =							np.full((rows, cols)  ,np.inf    )
			snake_case_					:       Dict =							0
			snake_case_					:       List[str] =							np.empty((rows, cols)  ,dtype=__lowerCamelCase    )
			snake_case_					:       List[str] =							None

			while queue:
						(snake_case_)					:       Any =							heappop(__lowerCamelCase    )
						if (x, y) in visited:
									continue
						visited.add((x, y)    )

						if (x, y) == destination:
									snake_case_					:       Tuple =							[]
									while (x, y) != source:
												path.append((x, y)    )
												snake_case_					:       List[Any] =							predecessors[x, y]
									path.append(__lowerCamelCase    )  # add the source manually
									path.reverse()
									return matrix[destination], path

						for i in range(len(__lowerCamelCase    )    ):
									snake_case_					:       Tuple =							x + dx[i], y + dy[i]
									if 0 <= nx < rows and 0 <= ny < cols:
												snake_case_					:       Optional[Any] =							grid[nx][ny]
												if next_node == 1 and matrix[nx, ny] > dist + 1:
															heappush(__lowerCamelCase  ,(dist + 1, (nx, ny))    )
															snake_case_					:       Optional[Any] =							dist + 1
															snake_case_					:       List[Any] =							(x, y)

			return np.inf, []


if __name__ == "__main__":
		import doctest

		doctest.testmod()






from typing import TYPE_CHECKING

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


__lowerCamelCase				=			{
    """configuration_chinese_clip""": [
        """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """ChineseCLIPConfig""",
        """ChineseCLIPOnnxConfig""",
        """ChineseCLIPTextConfig""",
        """ChineseCLIPVisionConfig""",
    ],
    """processing_chinese_clip""": ["""ChineseCLIPProcessor"""],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase				=			["""ChineseCLIPFeatureExtractor"""]
   __lowerCamelCase				=			["""ChineseCLIPImageProcessor"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   __lowerCamelCase				=			[
       """CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """ChineseCLIPModel""",
       """ChineseCLIPPreTrainedModel""",
       """ChineseCLIPTextModel""",
       """ChineseCLIPVisionModel""",
   ]

if TYPE_CHECKING:
   from .configuration_chinese_clip import (
       CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
       ChineseCLIPConfig,
       ChineseCLIPOnnxConfig,
       ChineseCLIPTextConfig,
       ChineseCLIPVisionConfig,
   )
   from .processing_chinese_clip import ChineseCLIPProcessor

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_chinese_clip import ChineseCLIPFeatureExtractor, ChineseCLIPImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_chinese_clip import (
          CHINESE_CLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
          ChineseCLIPModel,
          ChineseCLIPPreTrainedModel,
          ChineseCLIPTextModel,
          ChineseCLIPVisionModel,
      )

else:
   import sys

   __lowerCamelCase				=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





