
"""simple docstring"""







from pathlib import Path

from .config_args import default_config_file, load_config_from_file
from .config_utils import SubcommandHelpFormatter


SCREAMING_SNAKE_CASE_  					= 'Update an existing config file with the latest defaults while maintaining the old configuration.'
def       __UpperCAmelCase		(		a_      :		List[str]					)  ->							Tuple:
   _UpperCAmelCase 						=       args.config_file
   if config_file is None and Path(UpperCamelCase_					).exists():
      _UpperCAmelCase 						=       default_config_file
   elif not Path(UpperCamelCase_					).exists():
      raise ValueError(F'''The passed config file located at {config_file} doesn\'t exist.'''					)
   _UpperCAmelCase 						=       load_config_from_file(UpperCamelCase_					)

   if config_file.endswith(".json"					):
      config.to_json_file(UpperCamelCase_					)
   else:
      config.to_yaml_file(UpperCamelCase_					)
   return config_file
def       __UpperCAmelCase		(		a_      :		List[Any]     ,	a_      :		Tuple					)  ->							Optional[Any]:
   _UpperCAmelCase 						=       parser.add_parser("update"     ,	parents=UpperCamelCase_     ,	help=UpperCamelCase_     ,	formatter_class=UpperCamelCase_					)
   parser.add_argument(
       "--config_file"     ,	default=UpperCamelCase_     ,	help=(
           "The path to the config file to update. Will default to a file named default_config.yaml in the cache "
           "location, which is the content of the environment `HF_HOME` suffixed with 'accelerate', or if you don't have "
           "such an environment variable, your cache directory ('~/.cache' or the content of `XDG_CACHE_HOME`) suffixed "
           "with 'huggingface'."
       )     ,	)

   parser.set_defaults(func=UpperCamelCase_					)
   return parser


def       __UpperCAmelCase		(		a_      :		List[Any]					)  ->							Tuple:
   _UpperCAmelCase 						=       update_config(UpperCamelCase_					)
   print(F'''Sucessfully updated the configuration file at {config_file}.'''					)









"""simple docstring"""




from __future__ import annotations






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int  ,			UpperCamelCase_:				int       )							->				tuple[float, float]:







  '''simple docstring'''







  assert (
      c % greatest_common_divisor(UpperCamelCase_  ,			UpperCamelCase_       ) == 0
  )  # greatest_common_divisor(a,b) function implemented below
  ((_a)      ,						(_a)      ,						(_a))					      =						extended_gcd(UpperCamelCase_  ,			UpperCamelCase_       )  # extended_gcd(a,b) function implemented below
  _a					      =						c / d
  return (r * x, r * y)






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int  ,			UpperCamelCase_:				int  ,			UpperCamelCase_:				int = 2       )							->				None:







  '''simple docstring'''







  ((_a)      ,						(_a))					      =						diophantine(UpperCamelCase_  ,			UpperCamelCase_  ,			UpperCamelCase_       )  # Initial value
  _a					      =						greatest_common_divisor(UpperCamelCase_  ,			UpperCamelCase_       )
  _a					      =						a // d
  _a					      =						b // d

  for i in range(UpperCamelCase_       ):
    _a					      =						xa + i * q
    _a					      =						ya - i * p
    print(UpperCamelCase_  ,			UpperCamelCase_       )






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int       )							->				int:







  '''simple docstring'''







  if a < b:
    _a      ,						_a					      =						b, a

  while a % b != 0:
    _a      ,						_a					      =						b, a % b

  return b






def 							lowerCAmelCase			(   UpperCamelCase_:				int  ,			UpperCamelCase_:				int       )							->				tuple[int, int, int]:







  '''simple docstring'''







  assert a >= 0 and b >= 0

  if b == 0:
    _a      ,						_a      ,						_a					      =						a, 1, 0
  else:
    ((_a)      ,						(_a)      ,						(_a))					      =						extended_gcd(UpperCamelCase_  ,			a % b       )
    _a					      =						q
    _a					      =						p - q * (a // b)

  assert a % d == 0 and b % d == 0
  assert d == a * x + b * y

  return (d, x, y)


if __name__ == "__main__":
     from doctest import testmod

     testmod(name="""diophantine""", verbose=True)
     testmod(name="""diophantine_all_soln""", verbose=True)
     testmod(name="""extended_gcd""", verbose=True)
     testmod(name="""greatest_common_divisor""", verbose=True)


