


from __future__ import annotations

SCREAMING_SNAKE_CASE       :		Any         =				list[list[int]]

# assigning initial values to the grid
SCREAMING_SNAKE_CASE       :		Matrix         =				[
    [3, 0, 6, 5, 0, 8, 4, 0, 0],
    [5, 2, 0, 0, 0, 0, 0, 0, 0],
    [0, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]

# a grid with no solution
SCREAMING_SNAKE_CASE       :		Matrix         =				[
    [5, 0, 6, 5, 0, 8, 4, 0, 3],
    [5, 2, 0, 0, 0, 0, 0, 0, 2],
    [1, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]




def     UpperCamelCase    (      _a       ,		_a       ,		_a       ,		_a		)					->							bool:
     '''simple docstring'''





     for i in range(9		):
          if grid[row][i] == n or grid[i][column] == n:
               return False

     for i in range(3		):
          for j in range(3		):
               if grid[(row - row % 3) + i][(column - column % 3) + j] == n:
                    return False

     return True




def     UpperCamelCase    (      _a		)					->							tuple[int, int] | None:
     '''simple docstring'''





     for i in range(9		):
          for j in range(9		):
               if grid[i][j] == 0:
                    return i, j
     return None




def     UpperCamelCase    (      _a		)					->							Matrix | None:
     '''simple docstring'''





     if location := find_empty_location(_a		):
          lowercase_    ,      lowercase_       :Dict     =       location
     else:
          # If the location is ``None``, then the grid is solved.
          return grid

     for digit in range(1       ,		1_0		):
          if is_safe(_a       ,		_a       ,		_a       ,		_a		):
               lowercase_       :Tuple     =       digit

               if sudoku(_a		) is not None:
                    return grid

               lowercase_       :Optional[Any]     =       0

     return None




def     UpperCamelCase    (      _a		)					->							None:
     '''simple docstring'''





     for row in grid:
          for cell in row:
               print(_a       ,		end=''' '''		)
          print()


if __name__ == "__main__":
   # make a copy of grid so that you can compare with the unmodified grid
   for example_grid in (initial_grid, no_solution):
      print("\nExample grid:\n" + "=" * 20)
      print_solution(example_grid)
      print("\nExample grid solution:")
      SCREAMING_SNAKE_CASE       :		Optional[Any]         =				sudoku(example_grid)
      if solution is not None:
         print_solution(solution)
      else:
         print("Cannot find a solution.")





import argparse

import torch

from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()




def     UpperCamelCase    (      _a       ,		_a       ,		_a		)					->							List[str]:
     '''simple docstring'''





     if openai_config_file == "":
          lowercase_       :str     =       OpenAIGPTConfig()
     else:
          lowercase_       :int     =       OpenAIGPTConfig.from_json_file(_a		)
     lowercase_       :int     =       OpenAIGPTModel(_a		)

     # Load weights from numpy
     load_tf_weights_in_openai_gpt(_a       ,		_a       ,		_a		)

     # Save pytorch-model
     lowercase_       :Optional[int]     =       pytorch_dump_folder_path + '''/''' + WEIGHTS_NAME
     lowercase_       :List[str]     =       pytorch_dump_folder_path + '''/''' + CONFIG_NAME
     print(f"Save PyTorch model to {pytorch_weights_dump_path}"		)
     torch.save(model.state_dict()       ,		_a		)
     print(f"Save configuration file to {pytorch_config_dump_path}"		)
     with open(_a       ,		'''w'''       ,		encoding='''utf-8'''		) as f:
          f.write(config.to_json_string()		)


if __name__ == "__main__":
   SCREAMING_SNAKE_CASE       :		List[str]         =				argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       "--openai_checkpoint_folder_path",
       default=None,
       type=str,
       required=True,
       help="Path to the TensorFlow checkpoint path.",
   )
   parser.add_argument(
       "--pytorch_dump_folder_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
   )
   parser.add_argument(
       "--openai_config_file",
       default="",
       type=str,
       help=(
           "An optional config json file corresponding to the pre-trained OpenAI model. \n"
           "This specifies the model architecture."
       ),
   )
   SCREAMING_SNAKE_CASE       :		Optional[Any]         =				parser.parse_args()
   convert_openai_checkpoint_to_pytorch(
       args.openai_checkpoint_folder_path, args.openai_config_file, args.pytorch_dump_folder_path
   )

