


"""simple docstring"""


import numpy as np
import torch
import torch.nn as nn
from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel

from ...utils import logging


__lowerCamelCase      :List[str]	    =		logging.get_logger(__name__)


class 			A__	(						snake_case__):


     """simple docstring"""
     snake_case__	:					int													=CLIPConfig

     snake_case__	:					Dict													=['''CLIPEncoderLayer''']

     def __init__(	self:						Any     ,		__a:						int	)->    Optional[int]:
           super().__init__(lowercase_	)

           lowerCamelCase					:					Dict        =	CLIPVisionModelWithProjection(config.vision_config	)

           lowerCamelCase					:					List[str]        =	nn.Linear(config.vision_config.projection_dim     ,		1	)
           lowerCamelCase					:					Dict        =	nn.Linear(config.vision_config.projection_dim     ,		1	)







     @torch.no_grad()
     def 		a__						(	self:						Tuple     ,		__a:						List[str]     ,		__a:						List[Any]     ,		__a:						Optional[int]=0.5     ,		__a:						int=0.5	)->    Optional[int]:
           lowerCamelCase					:					Any        =	self.vision_model(lowercase_	)[0]

           lowerCamelCase					:					Optional[int]        =	self.p_head(lowercase_	)
           lowerCamelCase					:					Any        =	nsfw_detected.flatten()
           lowerCamelCase					:					Dict        =	nsfw_detected > p_threshold
           lowerCamelCase					:					Optional[int]        =	nsfw_detected.tolist()

           if any(lowercase_	):
                 logger.warning(
                     """Potential NSFW content was detected in one or more images. A black image will be returned instead."""
                     """ Try again with a different prompt and/or seed."""	)

           for idx, nsfw_detected_ in enumerate(lowercase_	):
                 if nsfw_detected_:
                       lowerCamelCase					:					Any        =	np.zeros(images[idx].shape	)

           lowerCamelCase					:					List[str]        =	self.w_head(lowercase_	)
           lowerCamelCase					:					Union[str, Any]        =	watermark_detected.flatten()
           lowerCamelCase					:					str        =	watermark_detected > w_threshold
           lowerCamelCase					:					str        =	watermark_detected.tolist()

           if any(lowercase_	):
                 logger.warning(
                     """Potential watermarked content was detected in one or more images. A black image will be returned instead."""
                     """ Try again with a different prompt and/or seed."""	)

           for idx, watermark_detected_ in enumerate(lowercase_	):
                 if watermark_detected_:
                       lowerCamelCase					:					List[Any]        =	np.zeros(images[idx].shape	)

           return images, nsfw_detected, watermark_detected








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




