


"""simple docstring"""


import unittest
from typing import Tuple

import torch

from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device
from diffusers.utils.testing_utils import require_torch


@require_torch
class 			A__	:


     """simple docstring"""

     @property
     def 		a__						(	self:						int	)->    List[Any]:
           return self.get_dummy_input()

     @property
     def 		a__						(	self:						Tuple	)->    Union[str, Any]:
           if self.block_type == "down":
                 return (4, 32, 16, 16)
           elif self.block_type == "mid":
                 return (4, 32, 32, 32)
           elif self.block_type == "up":
                 return (4, 32, 64, 64)

           raise ValueError(f'\'{self.block_type}\' is not a supported block_type. Set it to \'up\', \'mid\', or \'down\'.'	)

     def 		a__						(	self:						Union[str, Any]     ,		__a:						Any=True     ,		__a:						Optional[int]=False     ,		__a:						Dict=False     ,		__a:						List[str]=False     ,		)->    Union[str, Any]:
           lowerCamelCase					:					Tuple        =	4
           lowerCamelCase					:					Optional[int]        =	32
           lowerCamelCase					:					Union[str, Any]        =	(32, 32)

           lowerCamelCase					:					Optional[Any]        =	torch.manual_seed(0	)
           lowerCamelCase					:					List[str]        =	torch.device(__a	)
           lowerCamelCase					:					Dict        =	(batch_size, num_channels) + sizes
           lowerCamelCase					:					int        =	randn_tensor(__a     ,		generator=__a     ,		device=__a	)
           lowerCamelCase					:					List[Any]        =	{"""hidden_states""": hidden_states}

           if include_temb:
                 lowerCamelCase					:					Dict        =	128
                 lowerCamelCase					:					Union[str, Any]        =	randn_tensor((batch_size, temb_channels)     ,		generator=__a     ,		device=__a	)

           if include_res_hidden_states_tuple:
                 lowerCamelCase					:					List[str]        =	torch.manual_seed(1	)
                 lowerCamelCase					:					Any        =	(randn_tensor(__a     ,		generator=__a     ,		device=__a	),)

           if include_encoder_hidden_states:
                 lowerCamelCase					:					Optional[int]        =	floats_tensor((batch_size, 32, 32)	).to(__a	)

           if include_skip_sample:
                 lowerCamelCase					:					Tuple        =	randn_tensor(((batch_size, 3) + sizes)     ,		generator=__a     ,		device=__a	)

           return dummy_input

     def 		a__						(	self:						Dict	)->    Dict:
           lowerCamelCase					:					int        =	{
               """in_channels""": 32,
               """out_channels""": 32,
               """temb_channels""": 128,
           }
           if self.block_type == "up":
                 lowerCamelCase					:					Any        =	32

           if self.block_type == "mid":
                 init_dict.pop("""out_channels"""	)

           lowerCamelCase					:					Dict        =	self.dummy_input
           return init_dict, inputs_dict

     def 		a__						(	self:						str     ,		__a:						Dict	)->    Any:
           lowerCamelCase     ,			lowerCamelCase					:					str        =	self.prepare_init_args_and_inputs_for_common()
           lowerCamelCase					:					str        =	self.block_class(**__a	)
           unet_block.to(__a	)
           unet_block.eval()

           with torch.no_grad():
                 lowerCamelCase					:					Optional[int]        =	unet_block(**__a	)

           if isinstance(__a     ,		__a	):
                 lowerCamelCase					:					Any        =	output[0]

           self.assertEqual(output.shape     ,		self.output_shape	)

           lowerCamelCase					:					Dict        =	output[0, -1, -3:, -3:]
           lowerCamelCase					:					Dict        =	torch.tensor(__a	).to(__a	)
           assert torch_all_close(output_slice.flatten()     ,		__a     ,		atol=5e-3	)







     @unittest.skipIf(torch_device == """mps"""     ,		"""Training is not supported in mps"""	)
     def 		a__						(	self:						Union[str, Any]	)->    Tuple:
           lowerCamelCase     ,			lowerCamelCase					:					Union[str, Any]        =	self.prepare_init_args_and_inputs_for_common()
           lowerCamelCase					:					str        =	self.block_class(**__a	)
           model.to(__a	)
           model.train()
           lowerCamelCase					:					List[str]        =	model(**__a	)

           if isinstance(__a     ,		__a	):
                 lowerCamelCase					:					Any        =	output[0]

           lowerCamelCase					:					Union[str, Any]        =	torch.device(__a	)
           lowerCamelCase					:					List[str]        =	randn_tensor(output.shape     ,		device=__a	)
           lowerCamelCase					:					str        =	torch.nn.functional.mse_loss(__a     ,		__a	)
           loss.backward()








"""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())




