





"""simple docstring"""





# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pathlib import Path

import torch

from ...utils import is_npu_available, is_xpu_available
from .config_args import ClusterConfig, default_json_config_file
from .config_utils import SubcommandHelpFormatter


__A											=						"""Create a default config file for Accelerate with only a few flags set."""
def 					__A  (_SCREAMING_SNAKE_CASE="no"	,  _SCREAMING_SNAKE_CASE = default_json_config_file	,  _SCREAMING_SNAKE_CASE = False     )   ->List[str]:





  """simple docstring"""


  lowerCAmelCase__     :int											=				Path(_SCREAMING_SNAKE_CASE     )
  path.parent.mkdir(parents=_SCREAMING_SNAKE_CASE	,  exist_ok=_SCREAMING_SNAKE_CASE     )
  if path.exists():
    print(
        F"Configuration already exists at {save_location}, will not override. Run `accelerate config` manually or pass a different `save_location`."     )
    return False
  lowerCAmelCase__     :Tuple											=				mixed_precision.lower()
  if mixed_precision not in ["no", "fp16", "bf16", "fp8"]:
    raise ValueError(
        F"`mixed_precision` should be one of 'no', 'fp16', 'bf16', or 'fp8'. Received {mixed_precision}"     )
  lowerCAmelCase__     :Union[str, Any]											=				{
      'compute_environment': 'LOCAL_MACHINE',
      'mixed_precision': mixed_precision,
  }
  if torch.cuda.is_available():
    lowerCAmelCase__     :str											=				torch.cuda.device_count()
    lowerCAmelCase__     :Any											=				num_gpus
    lowerCAmelCase__     :Tuple											=				False
    if num_gpus > 1:
      lowerCAmelCase__     :int											=				'MULTI_GPU'
    else:
      lowerCAmelCase__     :int											=				'NO'
  elif is_xpu_available() and use_xpu:
    lowerCAmelCase__     :Optional[Any]											=				torch.xpu.device_count()
    lowerCAmelCase__     :Tuple											=				num_xpus
    lowerCAmelCase__     :List[str]											=				False
    if num_xpus > 1:
      lowerCAmelCase__     :Any											=				'MULTI_XPU'
    else:
      lowerCAmelCase__     :List[str]											=				'NO'
  elif is_npu_available():
    lowerCAmelCase__     :Optional[int]											=				torch.npu.device_count()
    lowerCAmelCase__     :Union[str, Any]											=				num_npus
    lowerCAmelCase__     :Optional[Any]											=				False
    if num_npus > 1:
      lowerCAmelCase__     :Dict											=				'MULTI_NPU'
    else:
      lowerCAmelCase__     :int											=				'NO'
  else:
    lowerCAmelCase__     :List[Any]											=				0
    lowerCAmelCase__     :Union[str, Any]											=				True
    lowerCAmelCase__     :str											=				1
    lowerCAmelCase__     :Optional[Any]											=				'NO'
  lowerCAmelCase__     :Optional[int]											=				ClusterConfig(**_SCREAMING_SNAKE_CASE     )
  config.to_json_file(_SCREAMING_SNAKE_CASE     )
  return path
def 					__A  (_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE     )   ->List[Any]:





  """simple docstring"""


  lowerCAmelCase__     :Dict											=				parser.add_parser('default'	,  parents=_SCREAMING_SNAKE_CASE	,  help=_SCREAMING_SNAKE_CASE	,  formatter_class=_SCREAMING_SNAKE_CASE     )
  parser.add_argument(
      '--config_file'	,  default=_SCREAMING_SNAKE_CASE	,  help=(
          'The path to use to store the config file. 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\'.'
      )	,  dest='save_location'	,  )

  parser.add_argument(
      '--mixed_precision'	,  choices=['no', 'fp16', 'bf16']	,  type=_SCREAMING_SNAKE_CASE	,  help='Whether or not to use mixed precision training. '
      'Choose between FP16 and BF16 (bfloat16) training. '
      'BF16 training is only supported on Nvidia Ampere GPUs and PyTorch 1.10 or later.'	,  default='no'	,  )
  parser.set_defaults(func=_SCREAMING_SNAKE_CASE     )
  return parser




def 					__A  (_SCREAMING_SNAKE_CASE     )   ->List[Any]:





  """simple docstring"""


  lowerCAmelCase__     :Any											=				write_basic_config(args.mixed_precision	,  args.save_location     )
  if config_file:
    print(F"accelerate configuration saved at {config_file}"     )







"""simple docstring"""





from __future__ import annotations

import math
def 					__A  (_SCREAMING_SNAKE_CASE     )   ->bool:





  """simple docstring"""


  if 1 < number < 4:
    # 2 and 3 are primes
    return True
  elif number < 2 or number % 2 == 0 or number % 3 == 0:
    # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
    return False

  # All primes number are in format of 6k +/- 1
  for i in range(5	,  int(math.sqrt(_SCREAMING_SNAKE_CASE     ) + 1     )	,  6     ):
    if number % i == 0 or number % (i + 2) == 0:
      return False
  return True


__A											=						[num for num in range(3, 10_0001, 2) if not is_prime(num)]
def 					__A  (_SCREAMING_SNAKE_CASE     )   ->list[int]:





  """simple docstring"""


  if not isinstance(_SCREAMING_SNAKE_CASE	,  _SCREAMING_SNAKE_CASE     ):
    raise ValueError('n must be an integer'     )
  if n <= 0:
    raise ValueError('n must be >= 0'     )

  lowerCAmelCase__     :Tuple											=				[]
  for num in range(len(_SCREAMING_SNAKE_CASE     )     ):
    lowerCAmelCase__     :int											=				0
    while 2 * i * i <= odd_composites[num]:
      lowerCAmelCase__     :int											=				odd_composites[num] - 2 * i * i
      if is_prime(_SCREAMING_SNAKE_CASE     ):
        break
      i += 1
    else:
      list_nums.append(odd_composites[num]     )
      if len(_SCREAMING_SNAKE_CASE     ) == n:
        return list_nums

  return []
def 					__A  ()   ->int:





  """simple docstring"""


  return compute_nums(1     )[0]


if __name__ == "__main__":
  print(F'''{solution() = }''')
