




import inspect
from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel, VQModel
from ...schedulers import DDIMScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput




class 		UpperCamelCase__	(lowerCAmelCase__     ):

    '''simple docstring'''



    def __init__(    self     ,  UpperCamelCase__     ,  UpperCamelCase__     ,  UpperCamelCase__     )     ->      List[Any]:
           super().__init__()
           self.register_modules(vqvae=UpperCamelCase__     ,  unet=UpperCamelCase__     ,  scheduler=UpperCamelCase__     )







    @torch.no_grad()
    def __call__(    self     ,  UpperCamelCase__ = 1     ,  UpperCamelCase__ = None     ,  UpperCamelCase__ = 0.0     ,  UpperCamelCase__ = 50     ,  UpperCamelCase__ = "pil"     ,  UpperCamelCase__ = True     ,  **UpperCamelCase__     ,  )     ->      Union[Tuple, ImagePipelineOutput]:
           lowerCamelCase   :      List[Any]			 =					randn_tensor(
               (batch_size, self.unet.config.in_channels, self.unet.config.sample_size, self.unet.config.sample_size)     ,  generator=UpperCamelCase__     ,  )
           lowerCamelCase   :      Any			 =					latents.to(self.device     )

           # scale the initial noise by the standard deviation required by the scheduler
           lowerCamelCase   :      Any			 =					latents * self.scheduler.init_noise_sigma

           self.scheduler.set_timesteps(UpperCamelCase__     )

           # prepare extra kwargs for the scheduler step, since not all schedulers have the same signature
           lowerCamelCase   :      Optional[int]			 =					"eta" in set(inspect.signature(self.scheduler.step     ).parameters.keys()     )

           lowerCamelCase   :      Union[str, Any]			 =					{}
           if accepts_eta:
                  lowerCamelCase   :      Tuple			 =					eta

           for t in self.progress_bar(self.scheduler.timesteps     ):
                  lowerCamelCase   :      int			 =					self.scheduler.scale_model_input(UpperCamelCase__     ,  UpperCamelCase__     )
                  # predict the noise residual
                  lowerCamelCase   :      int			 =					self.unet(UpperCamelCase__     ,  UpperCamelCase__     ).sample
                  # compute the previous noisy sample x_t -> x_t-1
                  lowerCamelCase   :      Tuple			 =					self.scheduler.step(UpperCamelCase__     ,  UpperCamelCase__     ,  UpperCamelCase__     ,  **UpperCamelCase__     ).prev_sample

           # decode the image latents with the VAE
           lowerCamelCase   :      List[str]			 =					self.vqvae.decode(UpperCamelCase__     ).sample

           lowerCamelCase   :      List[str]			 =					(image / 2 + 0.5).clamp(0     ,  1     )
           lowerCamelCase   :      List[Any]			 =					image.cpu().permute(0     ,  2     ,  3     ,  1     ).numpy()
           if output_type == "pil":
                  lowerCamelCase   :      str			 =					self.numpy_to_pil(UpperCamelCase__     )

           if not return_dict:
                  return (image,)

           return ImagePipelineOutput(images=UpperCamelCase__     )












def      A      (      _SCREAMING_SNAKE_CASE = 100_0000    )	-> int:
       lowerCamelCase   :      Tuple			 =					1
       lowerCamelCase   :      int			 =					1
       lowerCamelCase   :      Optional[Any]			 =					{1: 1}

       for inputa in range(2 ,_SCREAMING_SNAKE_CASE    ):
              lowerCamelCase   :      Union[str, Any]			 =					0
              lowerCamelCase   :      List[str]			 =					inputa

              while True:
                     if number in counters:
                            counter += counters[number]
                            break
                     if number % 2 == 0:
                            number //= 2
                            counter += 1
                     else:
                            lowerCamelCase   :      str			 =					(3 * number) + 1
                            counter += 1

              if inputa not in counters:
                     lowerCamelCase   :      str			 =					counter

              if counter > pre_counter:
                     lowerCamelCase   :      str			 =					inputa
                     lowerCamelCase   :      Any			 =					counter
       return largest_number


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






