


"""simple docstring"""




from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


__magic_name__	:   List[str]          =							logging.get_logger(__name__)  # pylint: disable=invalid-name




class  __snake_case      (lowerCamelCase     ):
							__a				   =					['''safety_checker''', '''feature_extractor''']




							def __init__(    self:						Tuple    ,       A_:						AutoencoderKL    ,       A_:						CLIPTextModel    ,       A_:						CLIPTokenizer    ,       A_:						UNetaDConditionModel    ,       A_:						Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]    ,       A_:						StableDiffusionSafetyChecker    ,       A_:						CLIPImageProcessor    ,       A_:						bool = True    ,       ):
										super().__init__()
										if hasattr(scheduler.config    ,       """steps_offset"""      ) and scheduler.config.steps_offset != 1:
													__lowerCamelCase        =			(
													    f'The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`'
													    f' should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure '
													    """to update the config accordingly as leaving `steps_offset` might led to incorrect results"""
													    """ in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,"""
													    """ it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`"""
													    """ file"""
													)
													deprecate("""steps_offset!=1"""    ,       """1.0.0"""    ,       A_    ,       standard_warn=A_      )
													__lowerCamelCase        =			dict(scheduler.config      )
													__lowerCamelCase        =			1
													__lowerCamelCase        =			FrozenDict(A_      )

										self.register_modules(
										    vae=A_    ,       text_encoder=A_    ,       tokenizer=A_    ,       unet=A_    ,       scheduler=A_    ,       safety_checker=A_    ,       feature_extractor=A_    ,       )
										self.register_to_config(requires_safety_checker=A_      )




							@property
							def      __a      (    self:						Optional[int]      ):
										return {k: getattr(self    ,       A_      ) for k in self.config.keys() if not k.startswith("""_"""      )}




							def      __a      (    self:						List[str]    ,       A_:						Optional[Union[str, int]] = "auto"      ):
										if slice_size == "auto":
													# half the attention head size is usually a good trade-off between
													# speed and memory
													__lowerCamelCase        =			self.unet.config.attention_head_dim // 2
										self.unet.set_attention_slice(A_      )




							def      __a      (    self:						Optional[Any]      ):
										self.enable_attention_slicing(A_      )




							@torch.no_grad()
							def      __a      (    self:						str    ,       A_:						Union[str, List[str]]    ,       A_:						Union[torch.FloatTensor, PIL.Image.Image]    ,       A_:						Union[torch.FloatTensor, PIL.Image.Image]    ,       A_:						float = 0.8    ,       A_:						Optional[int] = 50    ,       A_:						Optional[float] = 7.5    ,       A_:						Optional[Union[str, List[str]]] = None    ,       A_:						Optional[int] = 1    ,       A_:						Optional[float] = 0.0    ,       A_:						Optional[torch.Generator] = None    ,       A_:						Optional[str] = "pil"    ,       A_:						bool = True    ,       A_:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,       A_:						int = 1    ,       ):
										# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
										return StableDiffusionInpaintPipelineLegacy(**self.components      )(
										    prompt=A_    ,       image=A_    ,       mask_image=A_    ,       strength=A_    ,       num_inference_steps=A_    ,       guidance_scale=A_    ,       negative_prompt=A_    ,       num_images_per_prompt=A_    ,       eta=A_    ,       generator=A_    ,       output_type=A_    ,       return_dict=A_    ,       callback=A_    ,       )




							@torch.no_grad()
							def      __a      (    self:						Any    ,       A_:						Union[str, List[str]]    ,       A_:						Union[torch.FloatTensor, PIL.Image.Image]    ,       A_:						float = 0.8    ,       A_:						Optional[int] = 50    ,       A_:						Optional[float] = 7.5    ,       A_:						Optional[Union[str, List[str]]] = None    ,       A_:						Optional[int] = 1    ,       A_:						Optional[float] = 0.0    ,       A_:						Optional[torch.Generator] = None    ,       A_:						Optional[str] = "pil"    ,       A_:						bool = True    ,       A_:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,       A_:						int = 1    ,       **A_:						Optional[int]    ,       ):
										# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
										return StableDiffusionImgaImgPipeline(**self.components      )(
										    prompt=A_    ,       image=A_    ,       strength=A_    ,       num_inference_steps=A_    ,       guidance_scale=A_    ,       negative_prompt=A_    ,       num_images_per_prompt=A_    ,       eta=A_    ,       generator=A_    ,       output_type=A_    ,       return_dict=A_    ,       callback=A_    ,       callback_steps=A_    ,       )




							@torch.no_grad()
							def      __a      (    self:						List[str]    ,       A_:						Union[str, List[str]]    ,       A_:						int = 5_12    ,       A_:						int = 5_12    ,       A_:						int = 50    ,       A_:						float = 7.5    ,       A_:						Optional[Union[str, List[str]]] = None    ,       A_:						Optional[int] = 1    ,       A_:						float = 0.0    ,       A_:						Optional[torch.Generator] = None    ,       A_:						Optional[torch.FloatTensor] = None    ,       A_:						Optional[str] = "pil"    ,       A_:						bool = True    ,       A_:						Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,       A_:						int = 1    ,       ):
										# For more information on how this function https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline
										return StableDiffusionPipeline(**self.components      )(
										    prompt=A_    ,       height=A_    ,       width=A_    ,       num_inference_steps=A_    ,       guidance_scale=A_    ,       negative_prompt=A_    ,       num_images_per_prompt=A_    ,       eta=A_    ,       generator=A_    ,       latents=A_    ,       output_type=A_    ,       return_dict=A_    ,       callback=A_    ,       callback_steps=A_    ,       )








"""simple docstring"""




import os





def 			a_   (  ):
			__lowerCamelCase        =			os.path.dirname(os.path.realpath(lowercase__    )    )
			__lowerCamelCase        =			os.path.join(lowercase__, """triangle.txt"""    )

			with open(lowercase__    ) as in_file:
						__lowerCamelCase        =			[[int(lowercase__    ) for i in line.split()] for line in in_file]

			while len(lowercase__    ) != 1:
						__lowerCamelCase        =			triangle.pop()
						__lowerCamelCase        =			triangle[-1]
						for j in range(len(lowercase__    ) - 1    ):
									curr_row[j] += max(last_row[j], last_row[j + 1]    )
			return triangle[0][0]


if __name__ == "__main__":
					print(solution())




