



'''simple docstring'''





import warnings
from typing import List

import numpy as np

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
from ...utils import is_flax_available, is_tf_available, is_torch_available






class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_					):
  '''simple docstring'''




  __lowercase							:				List[Any]           =				['''image_processor''', '''tokenizer''']
  __lowercase							:				Optional[int]           =				'''OwlViTImageProcessor'''
  __lowercase							:				Dict           =				('''CLIPTokenizer''', '''CLIPTokenizerFast''')




  def __init__(   self  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,**__UpperCAmelCase				)   ->		Tuple:
      lowerCAmelCase__			:  Any											= None
      if "feature_extractor" in kwargs:
          warnings.warn(
              """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
              """ instead."""  ,__UpperCAmelCase  ,)
          lowerCAmelCase__			:  Dict											= kwargs.pop("""feature_extractor"""				)

      lowerCAmelCase__			:  List[str]											= image_processor if image_processor is not None else feature_extractor
      if image_processor is None:
          raise ValueError("""You need to specify an `image_processor`."""				)
      if tokenizer is None:
          raise ValueError("""You need to specify a `tokenizer`."""				)

      super().__init__(__UpperCAmelCase  ,__UpperCAmelCase				)




  def __call__(   self  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,__UpperCAmelCase=None  ,__UpperCAmelCase="max_length"  ,__UpperCAmelCase="np"  ,**__UpperCAmelCase				)   ->		List[str]:

      if text is None and query_images is None and images is None:
          raise ValueError(
              """You have to specify at least one text or query image or image. All three cannot be none."""				)

      if text is not None:
          if isinstance(__UpperCAmelCase  ,__UpperCAmelCase				) or (isinstance(__UpperCAmelCase  ,__UpperCAmelCase				) and not isinstance(text[0]  ,__UpperCAmelCase				)):
              lowerCAmelCase__			:  List[Any]											= [self.tokenizer(__UpperCAmelCase  ,padding=__UpperCAmelCase  ,return_tensors=__UpperCAmelCase  ,**__UpperCAmelCase				)]

          elif isinstance(__UpperCAmelCase  ,__UpperCAmelCase				) and isinstance(text[0]  ,__UpperCAmelCase				):
              lowerCAmelCase__			:  List[Any]											= []

              # Maximum number of queries across batch
              lowerCAmelCase__			:  str											= max([len(__UpperCAmelCase				) for t in text]				)

              # Pad all batch samples to max number of text queries
              for t in text:
                  if len(__UpperCAmelCase				) != max_num_queries:
                      lowerCAmelCase__			:  Optional[int]											= t + [""" """] * (max_num_queries - len(__UpperCAmelCase				))

                  lowerCAmelCase__			:  List[Any]											= self.tokenizer(__UpperCAmelCase  ,padding=__UpperCAmelCase  ,return_tensors=__UpperCAmelCase  ,**__UpperCAmelCase				)
                  encodings.append(__UpperCAmelCase				)
          else:
              raise TypeError("""Input text should be a string, a list of strings or a nested list of strings"""				)

          if return_tensors == "np":
              lowerCAmelCase__			:  str											= np.concatenate([encoding["""input_ids"""] for encoding in encodings]  ,axis=0				)
              lowerCAmelCase__			:  str											= np.concatenate([encoding["""attention_mask"""] for encoding in encodings]  ,axis=0				)

          elif return_tensors == "jax" and is_flax_available():
              import jax.numpy as jnp

              lowerCAmelCase__			:  Tuple											= jnp.concatenate([encoding["""input_ids"""] for encoding in encodings]  ,axis=0				)
              lowerCAmelCase__			:  int											= jnp.concatenate([encoding["""attention_mask"""] for encoding in encodings]  ,axis=0				)

          elif return_tensors == "pt" and is_torch_available():
              import torch

              lowerCAmelCase__			:  Optional[Any]											= torch.cat([encoding["""input_ids"""] for encoding in encodings]  ,dim=0				)
              lowerCAmelCase__			:  Optional[Any]											= torch.cat([encoding["""attention_mask"""] for encoding in encodings]  ,dim=0				)

          elif return_tensors == "tf" and is_tf_available():
              import tensorflow as tf

              lowerCAmelCase__			:  Tuple											= tf.stack([encoding["""input_ids"""] for encoding in encodings]  ,axis=0				)
              lowerCAmelCase__			:  List[str]											= tf.stack([encoding["""attention_mask"""] for encoding in encodings]  ,axis=0				)

          else:
              raise ValueError("""Target return tensor type could not be returned"""				)

          lowerCAmelCase__			:  Optional[int]											= BatchEncoding()
          lowerCAmelCase__			:  Optional[int]											= input_ids
          lowerCAmelCase__			:  int											= attention_mask

      if query_images is not None:
          lowerCAmelCase__			:  List[str]											= BatchEncoding()
          lowerCAmelCase__			:  List[Any]											= self.image_processor(
              __UpperCAmelCase  ,return_tensors=__UpperCAmelCase  ,**__UpperCAmelCase				).pixel_values
          lowerCAmelCase__			:  Optional[int]											= query_pixel_values

      if images is not None:
          lowerCAmelCase__			:  Any											= self.image_processor(__UpperCAmelCase  ,return_tensors=__UpperCAmelCase  ,**__UpperCAmelCase				)

      if text is not None and images is not None:
          lowerCAmelCase__			:  Optional[int]											= image_features.pixel_values
          return encoding
      elif query_images is not None and images is not None:
          lowerCAmelCase__			:  Optional[Any]											= image_features.pixel_values
          return encoding
      elif text is not None or query_images is not None:
          return encoding
      else:
          return BatchEncoding(data=dict(**__UpperCAmelCase				)  ,tensor_type=__UpperCAmelCase				)




  def 							UpperCAmelCase_     (   self  ,*__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		Dict:
      return self.image_processor.post_process(*__UpperCAmelCase  ,**__UpperCAmelCase				)




  def 							UpperCAmelCase_     (   self  ,*__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		Union[str, Any]:
      return self.image_processor.post_process_object_detection(*__UpperCAmelCase  ,**__UpperCAmelCase				)




  def 							UpperCAmelCase_     (   self  ,*__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		List[str]:
      return self.image_processor.post_process_image_guided_detection(*__UpperCAmelCase  ,**__UpperCAmelCase				)




  def 							UpperCAmelCase_     (   self  ,*__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		int:
      return self.tokenizer.batch_decode(*__UpperCAmelCase  ,**__UpperCAmelCase				)




  def 							UpperCAmelCase_     (   self  ,*__UpperCAmelCase  ,**__UpperCAmelCase				)   ->		Any:
      return self.tokenizer.decode(*__UpperCAmelCase  ,**__UpperCAmelCase				)




  @property
  def 							UpperCAmelCase_     (   self				)   ->		Dict:
      warnings.warn(
          """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""  ,__UpperCAmelCase  ,)
      return self.image_processor_class






  @property
  def 							UpperCAmelCase_     (   self				)   ->		List[Any]:
      warnings.warn(
          """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""  ,__UpperCAmelCase  ,)
      return self.image_processor







'''simple docstring'''





import os
def        _SCREAMING_SNAKE_CASE  (	UpperCamelCase      ):



    """simple docstring"""





    lowerCAmelCase__			:  List[str]											= len(grid[0]      )
    lowerCAmelCase__			:  int											= len(UpperCamelCase      )

    lowerCAmelCase__			:  Optional[int]											= 0
    lowerCAmelCase__			:  Tuple											= 0
    lowerCAmelCase__			:  Optional[Any]											= 0

    # Check vertically, horizontally, diagonally at the same time (only works
    # for nxn grid)
    for i in range(UpperCamelCase      ):
        for j in range(n_rows - 3      ):
            lowerCAmelCase__			:  str											= grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
            lowerCAmelCase__			:  Optional[int]											= grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

            # Left-to-right diagonal (\) product
            if i < n_columns - 3:
                lowerCAmelCase__			:  Optional[int]											= (
                    grid[i][j]
                    * grid[i + 1][j + 1]
                    * grid[i + 2][j + 2]
                    * grid[i + 3][j + 3]
                )

            # Right-to-left diagonal(/) product
            if i > 2:
                lowerCAmelCase__			:  Tuple											= (
                    grid[i][j]
                    * grid[i - 1][j + 1]
                    * grid[i - 2][j + 2]
                    * grid[i - 3][j + 3]
                )

            lowerCAmelCase__			:  Dict											= max(
                UpperCamelCase							,   UpperCamelCase							,   UpperCamelCase							,   UpperCamelCase      )
            if max_product > largest:
                lowerCAmelCase__			:  Any											= max_product

    return largest
def        _SCREAMING_SNAKE_CASE  (	):



    """simple docstring"""





    lowerCAmelCase__			:  List[str]											= []
    with open(os.path.dirname(UpperCamelCase      ) + """/grid.txt"""      ) as file:
        for line in file:
            grid.append(line.strip("""\n"""      ).split(""" """      )      )

    lowerCAmelCase__			:  Dict											= [[int(UpperCamelCase      ) for i in grid[j]] for j in range(len(UpperCamelCase      )      )]

    return largest_product(UpperCamelCase      )


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


