


'''simple docstring'''






from __future__ import annotations

__A :  Dict    							=				list[tuple[int, int]]

__A :  List[str]    							=				[
    [0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 0],  # 0 are free path whereas 1's are obstacles
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 0],
    [1, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0, 0],
]

__A :  List[Any]    							=				([-1, 0], [0, -1], [1, 0], [0, 1])  # up, left, down, right






class        __snake_case	:







    """simple docstring"""



    def __init__(       self   :  List[Any]   ,						lowerCamelCase   :  int   ,						lowerCamelCase   :  int   ,						lowerCamelCase   :  int   ,						lowerCamelCase   :  int   ,						lowerCamelCase   :  float   ,						lowerCamelCase   :  Node | None   ,						)       ->  Any:
      lowerCAmelCase_      :				Optional[int]      =       pos_x
      lowerCAmelCase_      :				str      =       pos_y
      lowerCAmelCase_      :				List[Any]      =       (pos_y, pos_x)
      lowerCAmelCase_      :				Optional[int]      =       goal_x
      lowerCAmelCase_      :				Dict      =       goal_y
      lowerCAmelCase_      :				Dict      =       g_cost
      lowerCAmelCase_      :				List[str]      =       parent
      lowerCAmelCase_      :				List[Any]      =       self.calculate_heuristic()

    def __lowercase       (       self   :  int		)       ->  float:
      lowerCAmelCase_      :				List[Any]      =       abs(self.pos_x - self.goal_x		)
      lowerCAmelCase_      :				Any      =       abs(self.pos_y - self.goal_y		)
      return dx + dy





    def __lt__(       self   :  Dict   ,						lowerCamelCase   :  int		)       ->  bool:
      return self.f_cost < other.f_cost







class        __snake_case	:







    """simple docstring"""



    def __init__(       self   :  Union[str, Any]   ,						lowerCamelCase   :  tuple[int, int]   ,						lowerCamelCase   :  tuple[int, int]		)       ->  int:
      lowerCAmelCase_      :				List[str]      =       Node(start[1]   ,						start[0]   ,						goal[1]   ,						goal[0]   ,						0   ,						lowerCamelCase		)
      lowerCAmelCase_      :				Tuple      =       Node(goal[1]   ,						goal[0]   ,						goal[1]   ,						goal[0]   ,						9_99_99   ,						lowerCamelCase		)

      lowerCAmelCase_      :				str      =       [self.start]
      lowerCAmelCase_      :				list[Node]      =       []

      lowerCAmelCase_      :				Any      =       False

    def __lowercase       (       self   :  List[Any]		)       ->  Path | None:
      while self.open_nodes:
        # Open Nodes are sorted using __lt__
        self.open_nodes.sort()
        lowerCAmelCase_      :				List[Any]      =       self.open_nodes.pop(0		)

        if current_node.pos == self.target.pos:
          lowerCAmelCase_      :				Optional[Any]      =       True
          return self.retrace_path(lowerCamelCase		)

        self.closed_nodes.append(lowerCamelCase		)
        lowerCAmelCase_      :				int      =       self.get_successors(lowerCamelCase		)

        for child_node in successors:
          if child_node in self.closed_nodes:
            continue

          if child_node not in self.open_nodes:
            self.open_nodes.append(lowerCamelCase		)
          else:
            # retrieve the best current path
            lowerCAmelCase_      :				Union[str, Any]      =       self.open_nodes.pop(self.open_nodes.index(lowerCamelCase		)		)

            if child_node.g_cost < better_node.g_cost:
              self.open_nodes.append(lowerCamelCase		)
            else:
              self.open_nodes.append(lowerCamelCase		)

      if not self.reached:
        return [self.start.pos]
      return None

    def __lowercase       (       self   :  Any   ,						lowerCamelCase   :  Node		)       ->  list[Node]:
      lowerCAmelCase_      :				List[str]      =       []
      for action in delta:
        lowerCAmelCase_      :				Dict      =       parent.pos_x + action[1]
        lowerCAmelCase_      :				Optional[Any]      =       parent.pos_y + action[0]

        if not (0 <= pos_x <= len(grid[0]		) - 1 and 0 <= pos_y <= len(lowerCamelCase		) - 1):
          continue

        if grid[pos_y][pos_x] != 0:
          continue

        successors.append(
            Node(
                lowerCamelCase   ,						lowerCamelCase   ,						self.target.pos_y   ,						self.target.pos_x   ,						parent.g_cost + 1   ,						lowerCamelCase   ,						)		)
      return successors





    def __lowercase       (       self   :  Optional[Any]   ,						lowerCamelCase   :  Node | None		)       ->  Path:
      lowerCAmelCase_      :				Tuple      =       node
      lowerCAmelCase_      :				Tuple      =       []
      while current_node is not None:
        path.append((current_node.pos_y, current_node.pos_x)		)
        lowerCAmelCase_      :				Dict      =       current_node.parent
      path.reverse()
      return path


if __name__ == "__main__":
  __A :  Any    							=				(0, 0)
  __A :  List[Any]    							=				(len(grid) - 1, len(grid[0]) - 1)
  for elem in grid:
    print(elem)

  print("------")

  __A :  int    							=				GreedyBestFirst(init, goal)
  __A :  Dict    							=				greedy_bf.search()
  if path:
    for pos_x, pos_y in path:
      __A :  Tuple    							=				2

    for elem in grid:
      print(elem)







'''simple docstring'''






import unittest

from diffusers.pipelines.pipeline_utils import is_safetensors_compatible






class        __snake_case	(       unittest.TestCase):







    """simple docstring"""



    def __lowercase       (       self   :  Tuple		)       ->  Dict:
      lowerCAmelCase_      :				str      =       [
          """safety_checker/pytorch_model.bin""",
          """safety_checker/model.safetensors""",
          """vae/diffusion_pytorch_model.bin""",
          """vae/diffusion_pytorch_model.safetensors""",
          """text_encoder/pytorch_model.bin""",
          """text_encoder/model.safetensors""",
          """unet/diffusion_pytorch_model.bin""",
          """unet/diffusion_pytorch_model.safetensors""",
      ]
      self.assertTrue(is_safetensors_compatible(lowerCamelCase		)		)

    def __lowercase       (       self   :  List[Any]		)       ->  int:
      lowerCAmelCase_      :				Tuple      =       [
          """unet/diffusion_pytorch_model.bin""",
          """unet/diffusion_pytorch_model.safetensors""",
      ]
      self.assertTrue(is_safetensors_compatible(lowerCamelCase		)		)

    def __lowercase       (       self   :  Optional[int]		)       ->  Optional[Any]:
      lowerCAmelCase_      :				int      =       [
          """safety_checker/pytorch_model.bin""",
          """safety_checker/model.safetensors""",
          """vae/diffusion_pytorch_model.bin""",
          """vae/diffusion_pytorch_model.safetensors""",
          """text_encoder/pytorch_model.bin""",
          """text_encoder/model.safetensors""",
          """unet/diffusion_pytorch_model.bin""",
          # Removed: 'unet/diffusion_pytorch_model.safetensors',
      ]
      self.assertFalse(is_safetensors_compatible(lowerCamelCase		)		)

    def __lowercase       (       self   :  int		)       ->  List[Any]:
      lowerCAmelCase_      :				Dict      =       [
          """text_encoder/pytorch_model.bin""",
          """text_encoder/model.safetensors""",
      ]
      self.assertTrue(is_safetensors_compatible(lowerCamelCase		)		)

    def __lowercase       (       self   :  str		)       ->  List[str]:
      lowerCAmelCase_      :				Union[str, Any]      =       [
          """safety_checker/pytorch_model.bin""",
          """safety_checker/model.safetensors""",
          """vae/diffusion_pytorch_model.bin""",
          """vae/diffusion_pytorch_model.safetensors""",
          """text_encoder/pytorch_model.bin""",
          # Removed: 'text_encoder/model.safetensors',
          """unet/diffusion_pytorch_model.bin""",
          """unet/diffusion_pytorch_model.safetensors""",
      ]
      self.assertFalse(is_safetensors_compatible(lowerCamelCase		)		)

    def __lowercase       (       self   :  List[Any]		)       ->  Tuple:
      lowerCAmelCase_      :				Union[str, Any]      =       [
          """safety_checker/pytorch_model.fp16.bin""",
          """safety_checker/model.fp16.safetensors""",
          """vae/diffusion_pytorch_model.fp16.bin""",
          """vae/diffusion_pytorch_model.fp16.safetensors""",
          """text_encoder/pytorch_model.fp16.bin""",
          """text_encoder/model.fp16.safetensors""",
          """unet/diffusion_pytorch_model.fp16.bin""",
          """unet/diffusion_pytorch_model.fp16.safetensors""",
      ]
      lowerCAmelCase_      :				Union[str, Any]      =       """fp16"""
      self.assertTrue(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)

    def __lowercase       (       self   :  Optional[Any]		)       ->  List[str]:
      lowerCAmelCase_      :				str      =       [
          """unet/diffusion_pytorch_model.fp16.bin""",
          """unet/diffusion_pytorch_model.fp16.safetensors""",
      ]
      lowerCAmelCase_      :				Optional[int]      =       """fp16"""
      self.assertTrue(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)

    def __lowercase       (       self   :  Tuple		)       ->  Optional[Any]:
      # pass variant but use the non-variant filenames
      lowerCAmelCase_      :				Dict      =       [
          """unet/diffusion_pytorch_model.bin""",
          """unet/diffusion_pytorch_model.safetensors""",
      ]
      lowerCAmelCase_      :				str      =       """fp16"""
      self.assertTrue(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)

    def __lowercase       (       self   :  Optional[int]		)       ->  List[str]:
      lowerCAmelCase_      :				str      =       [
          """safety_checker/pytorch_model.fp16.bin""",
          """safety_checker/model.fp16.safetensors""",
          """vae/diffusion_pytorch_model.fp16.bin""",
          """vae/diffusion_pytorch_model.fp16.safetensors""",
          """text_encoder/pytorch_model.fp16.bin""",
          """text_encoder/model.fp16.safetensors""",
          """unet/diffusion_pytorch_model.fp16.bin""",
          # Removed: 'unet/diffusion_pytorch_model.fp16.safetensors',
      ]
      lowerCAmelCase_      :				List[str]      =       """fp16"""
      self.assertFalse(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)

    def __lowercase       (       self   :  Union[str, Any]		)       ->  Optional[int]:
      lowerCAmelCase_      :				str      =       [
          """text_encoder/pytorch_model.fp16.bin""",
          """text_encoder/model.fp16.safetensors""",
      ]
      lowerCAmelCase_      :				Optional[Any]      =       """fp16"""
      self.assertTrue(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)

    def __lowercase       (       self   :  List[Any]		)       ->  List[Any]:
      # pass variant but use the non-variant filenames
      lowerCAmelCase_      :				Dict      =       [
          """text_encoder/pytorch_model.bin""",
          """text_encoder/model.safetensors""",
      ]
      lowerCAmelCase_      :				Any      =       """fp16"""
      self.assertTrue(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)





    def __lowercase       (       self   :  Dict		)       ->  Any:
      lowerCAmelCase_      :				Optional[int]      =       [
          """safety_checker/pytorch_model.fp16.bin""",
          """safety_checker/model.fp16.safetensors""",
          """vae/diffusion_pytorch_model.fp16.bin""",
          """vae/diffusion_pytorch_model.fp16.safetensors""",
          """text_encoder/pytorch_model.fp16.bin""",
          # 'text_encoder/model.fp16.safetensors',
          """unet/diffusion_pytorch_model.fp16.bin""",
          """unet/diffusion_pytorch_model.fp16.safetensors""",
      ]
      lowerCAmelCase_      :				int      =       """fp16"""
      self.assertFalse(is_safetensors_compatible(lowerCamelCase   ,						variant=lowerCamelCase		)		)



