"""simple docstring"""



from __future__ import annotations

__lowercase		:		Optional[Any]														=							[True] * 100_0001
__lowercase		:		Optional[Any]														=							2
while i * i <= 100_0000:
       if seive[i]:
              for j in range(i * i, 100_0001, i):
                     __lowercase		:		Dict														=							False
       i += 1





def    SCREAMING_SNAKE_CASE       (     snake_case):
     return seive[n]





def    SCREAMING_SNAKE_CASE       (     snake_case):
     return any(digit in '''02468''' for digit in str(lowerCamelCase__))





def    SCREAMING_SNAKE_CASE       (     snake_case = 1_00_00_00):
     __snake_case				=							[2]  # result already includes the number 2.
     for num in range(3,      limit + 1,      2):
          if is_prime(lowerCamelCase__) and not contains_an_even_digit(lowerCamelCase__):
               __snake_case				=							str(lowerCamelCase__)
               __snake_case				=							[int(str_num[j:] + str_num[:j]) for j in range(len(lowerCamelCase__))]
               if all(is_prime(lowerCamelCase__) for i in list_nums):
                    result.append(lowerCamelCase__)
     return result





def    SCREAMING_SNAKE_CASE       (     ):
     return len(find_circular_primes())


if __name__ == "__main__":
       print(F"""{len(find_circular_primes()) = }""")

"""simple docstring"""



import argparse
from pathlib import Path

import torch
from packaging import version
from torch.onnx import export

from diffusers import AutoencoderKL


__lowercase		:		int														=							version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11")





def    SCREAMING_SNAKE_CASE       (     snake_case,      snake_case,      snake_case,      snake_case,      snake_case,      snake_case,      snake_case,      snake_case=False,      ):
     output_path.parent.mkdir(parents=snake_case,      exist_ok=snake_case)
     # PyTorch deprecated the `enable_onnx_checker` and `use_external_data_format` arguments in v1.11,
     # so we check the torch version for backwards compatibility
     if is_torch_less_than_1_11:
          export(
              snake_case,      snake_case,      f=output_path.as_posix(),      input_names=snake_case,      output_names=snake_case,      dynamic_axes=snake_case,      do_constant_folding=snake_case,      use_external_data_format=snake_case,      enable_onnx_checker=snake_case,      opset_version=snake_case,      )
     else:
          export(
              snake_case,      snake_case,      f=output_path.as_posix(),      input_names=snake_case,      output_names=snake_case,      dynamic_axes=snake_case,      do_constant_folding=snake_case,      opset_version=snake_case,      )





@torch.no_grad()
def    SCREAMING_SNAKE_CASE       (     snake_case,      snake_case,      snake_case,      snake_case = False):
     __snake_case				=							torch.floataa if fpaa else torch.floataa
     if fpaa and torch.cuda.is_available():
          __snake_case				=							'''cuda'''
     elif fpaa and not torch.cuda.is_available():
          raise ValueError('''`float16` model export is only supported on GPUs with CUDA''')
     else:
          __snake_case				=							'''cpu'''
     __snake_case				=							Path(snake_case)

     # VAE DECODER
     __snake_case				=							AutoencoderKL.from_pretrained(model_path + '''/vae''')
     __snake_case				=							vae_decoder.config.latent_channels
     # forward only through the decoder part
     __snake_case				=							vae_decoder.decode
     onnx_export(
         snake_case,      model_args=(
             torch.randn(1,      snake_case,      25,      25).to(device=snake_case,      dtype=snake_case),
             False,
         ),      output_path=output_path / '''vae_decoder''' / '''model.onnx''',      ordered_input_names=['''latent_sample''', '''return_dict'''],      output_names=['''sample'''],      dynamic_axes={
             '''latent_sample''': {0: '''batch''', 1: '''channels''', 2: '''height''', 3: '''width'''},
         },      opset=snake_case,      )
     del vae_decoder


if __name__ == "__main__":
       __lowercase		:		Union[str, Any]														=							argparse.ArgumentParser()

       parser.add_argument(
           "--model_path",
           type=str,
           required=True,
           help="Path to the `diffusers` checkpoint to convert (either a local directory or on the Hub).",
       )

       parser.add_argument("--output_path", type=str, required=True, help="Path to the output model.")
       parser.add_argument(
           "--opset",
           default=14,
           type=int,
           help="The version of the ONNX operator set to use.",
       )
       parser.add_argument("--fp16", action="store_true", default=False, help="Export the models in `float16` mode")

       __lowercase		:		List[Any]														=							parser.parse_args()
       print(args.output_path)
       convert_models(args.model_path, args.output_path, args.opset, args.fpaa)
       print("SD: Done: ONNX")