





import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionPipeline
from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device


__lowerCamelCase			:	str					    =	False



class    A__  (			unittest.TestCase     ):
      pass



@nightly
@require_torch_gpu
class    A__  (			unittest.TestCase     ):





      def 			__UpperCamelCase(					self  ):
       '''simple docstring'''




       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()





      def 			__UpperCamelCase(					self  ):
       '''simple docstring'''




       UpperCamelCase      :   str			      =  VersatileDiffusionPipeline.from_pretrained("shi-labs/versatile-diffusion"			,				torch_dtype=torch.floataa  )
       pipe.to(__UpperCamelCase  )
       pipe.set_progress_bar_config(disable=__UpperCamelCase  )

       UpperCamelCase      :   Union[str, Any]			      =  load_image(
           "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"  )

       UpperCamelCase      :   Optional[Any]			      =  torch.manual_seed(0  )
       UpperCamelCase      :   str			      =  pipe.dual_guided(
           prompt="first prompt"			,				image=__UpperCamelCase			,				text_to_image_strength=0.75			,				generator=__UpperCamelCase			,				guidance_scale=7.5			,				num_inference_steps=2			,				output_type="numpy"			,				).images

       with tempfile.TemporaryDirectory() as tmpdirname:
        pipe.save_pretrained(__UpperCamelCase  )
        UpperCamelCase      :   str			      =  VersatileDiffusionPipeline.from_pretrained(__UpperCamelCase			,				torch_dtype=torch.floataa  )
       pipe.to(__UpperCamelCase  )
       pipe.set_progress_bar_config(disable=__UpperCamelCase  )

       UpperCamelCase      :   List[Any]			      =  generator.manual_seed(0  )
       UpperCamelCase      :   Optional[int]			      =  pipe.dual_guided(
           prompt="first prompt"			,				image=__UpperCamelCase			,				text_to_image_strength=0.75			,				generator=__UpperCamelCase			,				guidance_scale=7.5			,				num_inference_steps=2			,				output_type="numpy"			,				).images

       assert np.abs(image - new_image  ).sum() < 1e-5, "Models don't have the same forward pass"





      def 			__UpperCamelCase(					self  ):
       '''simple docstring'''




       UpperCamelCase      :   Any			      =  VersatileDiffusionPipeline.from_pretrained("shi-labs/versatile-diffusion"			,				torch_dtype=torch.floataa  )
       pipe.to(__UpperCamelCase  )
       pipe.set_progress_bar_config(disable=__UpperCamelCase  )

       UpperCamelCase      :   List[Any]			      =  "cyberpunk 2077"
       UpperCamelCase      :   Union[str, Any]			      =  load_image(
           "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg"  )
       UpperCamelCase      :   Optional[Any]			      =  torch.manual_seed(0  )
       UpperCamelCase      :   Optional[int]			      =  pipe.dual_guided(
           prompt=__UpperCamelCase			,				image=__UpperCamelCase			,				text_to_image_strength=0.75			,				generator=__UpperCamelCase			,				guidance_scale=7.5			,				num_inference_steps=50			,				output_type="numpy"			,				).images

       UpperCamelCase      :   Any			      =  image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       UpperCamelCase      :   Dict			      =  np.array([0.14_48, 0.16_19, 0.17_41, 0.10_86, 0.11_47, 0.11_28, 0.11_99, 0.11_65, 0.10_01]  )

       assert np.abs(image_slice.flatten() - expected_slice  ).max() < 1e-1

       UpperCamelCase      :   Tuple			      =  "A painting of a squirrel eating a burger "
       UpperCamelCase      :   Optional[Any]			      =  torch.manual_seed(0  )
       UpperCamelCase      :   str			      =  pipe.text_to_image(
           prompt=__UpperCamelCase			,				generator=__UpperCamelCase			,				guidance_scale=7.5			,				num_inference_steps=50			,				output_type="numpy"  ).images

       UpperCamelCase      :   Dict			      =  image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       UpperCamelCase      :   str			      =  np.array([0.33_67, 0.31_69, 0.26_56, 0.38_70, 0.47_90, 0.37_96, 0.40_09, 0.48_78, 0.47_78]  )

       assert np.abs(image_slice.flatten() - expected_slice  ).max() < 1e-1

       UpperCamelCase      :   List[Any]			      =  pipe.image_variation(__UpperCamelCase			,				generator=__UpperCamelCase			,				output_type="numpy"  ).images

       UpperCamelCase      :   Union[str, Any]			      =  image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       UpperCamelCase      :   Any			      =  np.array([0.30_76, 0.31_23, 0.32_84, 0.37_82, 0.37_70, 0.38_94, 0.42_97, 0.43_31, 0.44_56]  )

       assert np.abs(image_slice.flatten() - expected_slice  ).max() < 1e-1





from collections.abc import Sequence






def  lowerCamelCase_	(      lowerCAmelCase__	:	Sequence[int] | None = None				)       ->							int:

							'''simple docstring'''






							if nums is None or not nums:
														raise ValueError('Input sequence should not be empty'				)

							A      						=    nums[0]
							for i in range(1			,	len(lowerCAmelCase__				)				):
														A      						=    nums[i]
														A      						=    max(lowerCAmelCase__			,	ans + num			,	lowerCAmelCase__				)

							return ans


if __name__ == "__main__":
				import doctest

				doctest.testmod()

				# Try on a sample input from the user
				__snake_case     :str			       =int(input('Enter number of elements : ').strip())
				__snake_case     :Optional[int]			       =list(map(int, input('\nEnter the numbers : ').strip().split()))[:n]
				print(max_subsequence_sum(array))