
"""simple docstring"""



import argparse
from pathlib import Path

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

from diffusers import AutoencoderKL


a       :						Dict       		=		version.parse(version.parse(torch.__version__).base_version) < version.parse('''1.11''')


def 			_UpperCamelCase						(    _A       ,   _A       ,   _A       ,   _A       ,   _A       ,   _A       ,   _A       ,   _A=False       ,   )     ->	str:





    """simple docstring"""

    output_path.parent.mkdir(parents=_A       ,   exist_ok=_A   )
    # 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(
            _A       ,   _A       ,   f=output_path.as_posix()       ,   input_names=_A       ,   output_names=_A       ,   dynamic_axes=_A       ,   do_constant_folding=_A       ,   use_external_data_format=_A       ,   enable_onnx_checker=_A       ,   opset_version=_A       ,   )
    else:
        export(
            _A       ,   _A       ,   f=output_path.as_posix()       ,   input_names=_A       ,   output_names=_A       ,   dynamic_axes=_A       ,   do_constant_folding=_A       ,   opset_version=_A       ,   )


@torch.no_grad()
def 			_UpperCamelCase						(    _A       ,   _A       ,   _A       ,   _A = False   )     ->	Dict:





    """simple docstring"""

    _UpperCAmelCase        = torch.floataa if fpaa else torch.floataa
    if fpaa and torch.cuda.is_available():
        _UpperCAmelCase        = """cuda"""
    elif fpaa and not torch.cuda.is_available():
        raise ValueError("""`float16` model export is only supported on GPUs with CUDA"""   )
    else:
        _UpperCAmelCase        = """cpu"""
    _UpperCAmelCase        = Path(_A   )

    # VAE DECODER
    _UpperCAmelCase        = AutoencoderKL.from_pretrained(model_path + """/vae"""   )
    _UpperCAmelCase        = vae_decoder.config.latent_channels
    # forward only through the decoder part
    _UpperCAmelCase        = vae_decoder.decode
    onnx_export(
        _A       ,   model_args=(
            torch.randn(1       ,   _A       ,   2_5       ,   2_5   ).to(device=_A       ,   dtype=_A   ),
            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=_A       ,   )
    del vae_decoder


if __name__ == "__main__":
 a       :						List[str]       		=		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=1_4,
     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''')

 a       :						Dict       		=		parser.parse_args()
 print(args.output_path)
 convert_models(args.model_path, args.output_path, args.opset, args.fpaa)
 print('''SD: Done: ONNX''')

"""simple docstring"""



def 			_UpperCamelCase						(    _A = 1_0_0_0   )     ->	int:





    """simple docstring"""

    _UpperCAmelCase     ,_UpperCAmelCase        = 1, 1
    _UpperCAmelCase        = 2
    while True:
        _UpperCAmelCase        = 0
        _UpperCAmelCase        = fa + fa
        _UpperCAmelCase     ,_UpperCAmelCase        = fa, f
        index += 1
        for _ in str(_A   ):
            i += 1
        if i == n:
            break
    return index


if __name__ == "__main__":
 print(solution(int(str(input()).strip())))