


"""simple docstring"""


import random
import unittest

import torch

from diffusers import IFInpaintingSuperResolutionPipeline
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_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin


@skip_mps
class 			A__	(						__lowercase ,     __lowercase ,     unittest.TestCase):


     """simple docstring"""
     snake_case__	:					Optional[int]													=IFInpaintingSuperResolutionPipeline
     snake_case__	:					Tuple													=TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'''width''', '''height'''}
     snake_case__	:					Dict													=TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({'''original_image'''})
     snake_case__	:					Optional[Any]													=PipelineTesterMixin.required_optional_params - {'''latents'''}

     def 		a__						(	self:						Optional[Any]	)->    Tuple:
           return self._get_superresolution_dummy_components()

     def 		a__						(	self:						List[Any]     ,		__a:						List[Any]     ,		__a:						int=0	)->    List[str]:
           if str(__a	).startswith("""mps"""	):
                 lowerCamelCase					:					List[Any]        =	torch.manual_seed(__a	)
           else:
                 lowerCamelCase					:					Dict        =	torch.Generator(device=__a	).manual_seed(__a	)

           lowerCamelCase					:					Any        =	floats_tensor((1, 3, 16, 16)     ,		rng=random.Random(__a	)	).to(__a	)
           lowerCamelCase					:					Tuple        =	floats_tensor((1, 3, 32, 32)     ,		rng=random.Random(__a	)	).to(__a	)
           lowerCamelCase					:					Union[str, Any]        =	floats_tensor((1, 3, 32, 32)     ,		rng=random.Random(__a	)	).to(__a	)

           lowerCamelCase					:					List[str]        =	{
               """prompt""": """A painting of a squirrel eating a burger""",
               """image""": image,
               """original_image""": original_image,
               """mask_image""": mask_image,
               """generator""": generator,
               """num_inference_steps""": 2,
               """output_type""": """numpy""",
           }

           return inputs

     @unittest.skipIf(
         torch_device != """cuda""" or not is_xformers_available()     ,		reason="""XFormers attention is only available with CUDA and `xformers` installed"""     ,		)
     def 		a__						(	self:						Optional[int]	)->    int:
           self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3	)

     def 		a__						(	self:						Any	)->    Tuple:
           self._test_save_load_optional_components()

     @unittest.skipIf(torch_device != """cuda"""     ,		reason="""float16 requires CUDA"""	)
     def 		a__						(	self:						List[Any]	)->    Any:
           # 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	)

     def 		a__						(	self:						Optional[Any]	)->    Optional[int]:
           self._test_attention_slicing_forward_pass(expected_max_diff=1e-2	)

     def 		a__						(	self:						Optional[Any]	)->    int:
           self._test_save_load_local()







     def 		a__						(	self:						Dict	)->    List[str]:
           self._test_inference_batch_single_identical(
               expected_max_diff=1e-2     ,		)








"""simple docstring"""


import os




def   snake_case		(     )   ->      Optional[Any]:
      with open(os.path.dirname(UpperCamelCase__    ) + """/grid.txt"""    ) as f:
            lowerCamelCase					:					int        =	[]  # noqa: E741
            for _ in range(20    ):
                  l.append([int(UpperCamelCase__    ) for x in f.readline().split()]    )

            lowerCamelCase					:					Union[str, Any]        =	0

            # right
            for i in range(20    ):
                  for j in range(17    ):
                        lowerCamelCase					:					Dict        =	l[i][j] * l[i][j + 1] * l[i][j + 2] * l[i][j + 3]
                        if temp > maximum:
                              lowerCamelCase					:					Tuple        =	temp

        # down
            for i in range(17    ):
                  for j in range(20    ):
                        lowerCamelCase					:					Any        =	l[i][j] * l[i + 1][j] * l[i + 2][j] * l[i + 3][j]
                        if temp > maximum:
                              lowerCamelCase					:					Optional[Any]        =	temp

        # diagonal 1
            for i in range(17    ):
                  for j in range(17    ):
                        lowerCamelCase					:					List[Any]        =	l[i][j] * l[i + 1][j + 1] * l[i + 2][j + 2] * l[i + 3][j + 3]
                        if temp > maximum:
                              lowerCamelCase					:					List[str]        =	temp

        # diagonal 2
            for i in range(17    ):
                  for j in range(3			,				20    ):
                        lowerCamelCase					:					List[str]        =	l[i][j] * l[i + 1][j - 1] * l[i + 2][j - 2] * l[i + 3][j - 3]
                        if temp > maximum:
                              lowerCamelCase					:					List[Any]        =	temp
            return maximum


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




