

import random
import unittest

import torch

from diffusers import IFImgaImgPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin



@skip_mps
class 						a_			(				lowerCamelCase_					,     lowerCamelCase_					,     unittest.TestCase	):



      """simple docstring"""







      __UpperCAmelCase     						= IFImgaImgPipeline
      __UpperCAmelCase     						= TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'width', 'height'}
      __UpperCAmelCase     						= TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
      __UpperCAmelCase     						= PipelineTesterMixin.required_optional_params - {'latents'}
      def 			_lowerCAmelCase	( self	:				Dict							):
           return self._get_dummy_components()
      def 			_lowerCAmelCase	( self	:				Any     ,snake_case	:				List[Any]     ,snake_case	:				int=0							):
           if str(snake_case							).startswith('mps'							):
                SCREAMING_SNAKE_CASE 		=torch.manual_seed(snake_case							)
           else:
                SCREAMING_SNAKE_CASE 		=torch.Generator(device=snake_case							).manual_seed(snake_case							)

           SCREAMING_SNAKE_CASE 		=floats_tensor((1, 3, 32, 32)     ,rng=random.Random(snake_case							)							).to(snake_case							)

           SCREAMING_SNAKE_CASE 		={
               'prompt': 'A painting of a squirrel eating a burger',
               'image': image,
               'generator': generator,
               'num_inference_steps': 2,
               'output_type': 'numpy',
           }

           return inputs
      def 			_lowerCAmelCase	( self	:				Tuple							):
           self._test_save_load_optional_components()
      @unittest.skipIf(
          torch_device != 'cuda' or not is_xformers_available()     ,reason='XFormers attention is only available with CUDA and `xformers` installed'     ,)
      def 			_lowerCAmelCase	( self	:				Any							):
           self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3							)
      @unittest.skipIf(torch_device != 'cuda'     ,reason='float16 requires CUDA'							)
      def 			_lowerCAmelCase	( self	:				List[str]							):
           # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
           super().test_save_load_floataa(expected_max_diff=1e-1							)
      @unittest.skipIf(torch_device != 'cuda'     ,reason='float16 requires CUDA'							)
      def 			_lowerCAmelCase	( self	:				Optional[Any]							):
           super().test_floataa_inference(expected_max_diff=1e-1							)
      def 			_lowerCAmelCase	( self	:				List[Any]							):
           self._test_attention_slicing_forward_pass(expected_max_diff=1e-2							)
      def 			_lowerCAmelCase	( self	:				Optional[int]							):
           self._test_save_load_local()


      def 			_lowerCAmelCase	( self	:				Any							):
           self._test_inference_batch_single_identical(
               expected_max_diff=1e-2     ,)




import os







def      snake_case__							(  ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE 		=os.path.dirname(os.path.realpath(lowerCAmelCase_     )     )
     SCREAMING_SNAKE_CASE 		=os.path.join(lowerCAmelCase_,       'triangle.txt'     )

     with open(lowerCAmelCase_     ) as f:
          SCREAMING_SNAKE_CASE 		=f.readlines()

     SCREAMING_SNAKE_CASE 		=[[int(lowerCAmelCase_     ) for y in x.rstrip('\r\n'     ).split(' '     )] for x in triangle]

     for i in range(1,       len(lowerCAmelCase_     )     ):
          for j in range(len(a[i]     )     ):
               SCREAMING_SNAKE_CASE 		=a[i - 1][j] if j != len(a[i - 1]     ) else 0
               SCREAMING_SNAKE_CASE 		=a[i - 1][j - 1] if j > 0 else 0
               a[i][j] += max(lowerCAmelCase_,       lowerCAmelCase_     )
     return max(a[-1]     )


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

