


'''simple docstring'''






import os







def     UpperCamelCase_      (   ):
  '''simple docstring'''





  with open(os.path.dirname(A__ ) + """/grid.txt""" ) as f:
    lowerCAmelCase_      :				Union[str, Any]      =       []  # noqa: E741
    for _ in range(20 ):
      l.append([int(A__ ) 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_      :				Union[str, Any]      =       temp

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

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

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


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







'''simple docstring'''






from dataclasses import dataclass
from typing import Optional, Tuple, Union

import torch
import torch.nn as nn

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps
from .modeling_utils import ModelMixin
from .unet_ad_blocks import get_down_block, get_mid_block, get_out_block, get_up_block






@dataclass
class        __snake_case	(       _SCREAMING_SNAKE_CASE):







    """simple docstring"""



    lowercase       			= 42







class        __snake_case	(       _SCREAMING_SNAKE_CASE     ,_SCREAMING_SNAKE_CASE):







    """simple docstring"""



    @register_to_config
    def __init__(       self   :  Optional[int]   ,						lowerCamelCase   :  int = 6_55_36   ,						lowerCamelCase   :  Optional[int] = None   ,						lowerCamelCase   :  int = 2   ,						lowerCamelCase   :  int = 2   ,						lowerCamelCase   :  int = 0   ,						lowerCamelCase   :  str = "fourier"   ,						lowerCamelCase   :  bool = True   ,						lowerCamelCase   :  bool = False   ,						lowerCamelCase   :  float = 0.0   ,						lowerCamelCase   :  Tuple[str] = ("DownBlock1DNoSkip", "DownBlock1D", "AttnDownBlock1D")   ,						lowerCamelCase   :  Tuple[str] = ("AttnUpBlock1D", "UpBlock1D", "UpBlock1DNoSkip")   ,						lowerCamelCase   :  Tuple[str] = "UNetMidBlock1D"   ,						lowerCamelCase   :  str = None   ,						lowerCamelCase   :  Tuple[int] = (32, 32, 64)   ,						lowerCamelCase   :  str = None   ,						lowerCamelCase   :  int = 8   ,						lowerCamelCase   :  int = 1   ,						lowerCamelCase   :  bool = False   ,						)       ->  List[Any]:
      super().__init__()
      lowerCAmelCase_      :				Optional[Any]      =       sample_size

      # time
      if time_embedding_type == "fourier":
        lowerCAmelCase_      :				int      =       GaussianFourierProjection(
            embedding_size=8   ,						set_W_to_weight=lowerCamelCase   ,						log=lowerCamelCase   ,						flip_sin_to_cos=lowerCamelCase		)
        lowerCAmelCase_      :				List[Any]      =       2 * block_out_channels[0]
      elif time_embedding_type == "positional":
        lowerCAmelCase_      :				Optional[int]      =       Timesteps(
            block_out_channels[0]   ,						flip_sin_to_cos=lowerCamelCase   ,						downscale_freq_shift=lowerCamelCase		)
        lowerCAmelCase_      :				Union[str, Any]      =       block_out_channels[0]

      if use_timestep_embedding:
        lowerCAmelCase_      :				List[str]      =       block_out_channels[0] * 4
        lowerCAmelCase_      :				List[str]      =       TimestepEmbedding(
            in_channels=lowerCamelCase   ,						time_embed_dim=lowerCamelCase   ,						act_fn=lowerCamelCase   ,						out_dim=block_out_channels[0]   ,						)

      lowerCAmelCase_      :				str      =       nn.ModuleList([]		)
      lowerCAmelCase_      :				Tuple      =       None
      lowerCAmelCase_      :				str      =       nn.ModuleList([]		)
      lowerCAmelCase_      :				List[str]      =       None

      # down
      lowerCAmelCase_      :				List[str]      =       in_channels
      for i, down_block_type in enumerate(lowerCamelCase		):
        lowerCAmelCase_      :				Optional[Any]      =       output_channel
        lowerCAmelCase_      :				str      =       block_out_channels[i]

        if i == 0:
          input_channel += extra_in_channels

        lowerCAmelCase_      :				int      =       i == len(lowerCamelCase		) - 1

        lowerCAmelCase_      :				List[str]      =       get_down_block(
            lowerCamelCase   ,						num_layers=lowerCamelCase   ,						in_channels=lowerCamelCase   ,						out_channels=lowerCamelCase   ,						temb_channels=block_out_channels[0]   ,						add_downsample=not is_final_block or downsample_each_block   ,						)
        self.down_blocks.append(lowerCamelCase		)

      # mid
      lowerCAmelCase_      :				Dict      =       get_mid_block(
          lowerCamelCase   ,						in_channels=block_out_channels[-1]   ,						mid_channels=block_out_channels[-1]   ,						out_channels=block_out_channels[-1]   ,						embed_dim=block_out_channels[0]   ,						num_layers=lowerCamelCase   ,						add_downsample=lowerCamelCase   ,						)

      # up
      lowerCAmelCase_      :				List[str]      =       list(reversed(lowerCamelCase		)		)
      lowerCAmelCase_      :				str      =       reversed_block_out_channels[0]
      if out_block_type is None:
        lowerCAmelCase_      :				Optional[int]      =       out_channels
      else:
        lowerCAmelCase_      :				Optional[Any]      =       block_out_channels[0]

      for i, up_block_type in enumerate(lowerCamelCase		):
        lowerCAmelCase_      :				Any      =       output_channel
        lowerCAmelCase_      :				str      =       (
            reversed_block_out_channels[i + 1] if i < len(lowerCamelCase		) - 1 else final_upsample_channels
        )

        lowerCAmelCase_      :				int      =       i == len(lowerCamelCase		) - 1

        lowerCAmelCase_      :				Any      =       get_up_block(
            lowerCamelCase   ,						num_layers=lowerCamelCase   ,						in_channels=lowerCamelCase   ,						out_channels=lowerCamelCase   ,						temb_channels=block_out_channels[0]   ,						add_upsample=not is_final_block   ,						)
        self.up_blocks.append(lowerCamelCase		)
        lowerCAmelCase_      :				Optional[int]      =       output_channel

      # out
      lowerCAmelCase_      :				str      =       norm_num_groups if norm_num_groups is not None else min(block_out_channels[0] // 4   ,						32		)
      lowerCAmelCase_      :				Union[str, Any]      =       get_out_block(
          out_block_type=lowerCamelCase   ,						num_groups_out=lowerCamelCase   ,						embed_dim=block_out_channels[0]   ,						out_channels=lowerCamelCase   ,						act_fn=lowerCamelCase   ,						fc_dim=block_out_channels[-1] // 4   ,						)





    def __lowercase       (       self   :  List[Any]   ,						lowerCamelCase   :  torch.FloatTensor   ,						lowerCamelCase   :  Union[torch.Tensor, float, int]   ,						lowerCamelCase   :  bool = True   ,						)       ->  Union[UNetaDOutput, Tuple]:
      lowerCAmelCase_      :				Optional[Any]      =       timestep
      if not torch.is_tensor(lowerCamelCase		):
        lowerCAmelCase_      :				Any      =       torch.tensor([timesteps]   ,						dtype=torch.long   ,						device=sample.device		)
      elif torch.is_tensor(lowerCamelCase		) and len(timesteps.shape		) == 0:
        lowerCAmelCase_      :				Dict      =       timesteps[None].to(sample.device		)

      lowerCAmelCase_      :				int      =       self.time_proj(lowerCamelCase		)
      if self.config.use_timestep_embedding:
        lowerCAmelCase_      :				int      =       self.time_mlp(lowerCamelCase		)
      else:
        lowerCAmelCase_      :				Tuple      =       timestep_embed[..., None]
        lowerCAmelCase_      :				Dict      =       timestep_embed.repeat([1, 1, sample.shape[2]]		).to(sample.dtype		)
        lowerCAmelCase_      :				Union[str, Any]      =       timestep_embed.broadcast_to((sample.shape[:1] + timestep_embed.shape[1:])		)

      # 2. down
      lowerCAmelCase_      :				Optional[Any]      =       ()
      for downsample_block in self.down_blocks:
        lowerCAmelCase_,							lowerCAmelCase_      :				Any      =       downsample_block(hidden_states=lowerCamelCase   ,						temb=lowerCamelCase		)
        down_block_res_samples += res_samples

      # 3. mid
      if self.mid_block:
        lowerCAmelCase_      :				int      =       self.mid_block(lowerCamelCase   ,						lowerCamelCase		)

      # 4. up
      for i, upsample_block in enumerate(self.up_blocks		):
        lowerCAmelCase_      :				str      =       down_block_res_samples[-1:]
        lowerCAmelCase_      :				Union[str, Any]      =       down_block_res_samples[:-1]
        lowerCAmelCase_      :				List[str]      =       upsample_block(lowerCamelCase   ,						res_hidden_states_tuple=lowerCamelCase   ,						temb=lowerCamelCase		)

      # 5. post-process
      if self.out_block:
        lowerCAmelCase_      :				Union[str, Any]      =       self.out_block(lowerCamelCase   ,						lowerCamelCase		)

      if not return_dict:
        return (sample,)

      return UNetaDOutput(sample=lowerCamelCase		)



