






'''simple docstring'''







import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import ConvNextImageProcessor




class      __SCREAMING_SNAKE_CASE					(unittest.TestCase					):


  """simple docstring"""


  def __init__( self      ,  UpperCamelCase__      ,  UpperCamelCase__=7      ,  UpperCamelCase__=3      ,  UpperCamelCase__=18      ,  UpperCamelCase__=30      ,  UpperCamelCase__=400      ,  UpperCamelCase__=True      ,  UpperCamelCase__=None      ,  UpperCamelCase__=0.875      ,  UpperCamelCase__=True      ,  UpperCamelCase__=[0.5, 0.5, 0.5]      ,  UpperCamelCase__=[0.5, 0.5, 0.5]      ,  ):






         """simple docstring"""


         a_	    = size if size is not None else {'shortest_edge': 20}
         a_	    = parent
         a_	    = batch_size
         a_	    = num_channels
         a_	    = image_size
         a_	    = min_resolution
         a_	    = max_resolution
         a_	    = do_resize
         a_	    = size
         a_	    = crop_pct
         a_	    = do_normalize
         a_	    = image_mean
         a_	    = image_std







  def       _a					( self  ):






         """simple docstring"""


         return {
             "image_mean": self.image_mean,
             "image_std": self.image_std,
             "do_normalize": self.do_normalize,
             "do_resize": self.do_resize,
             "size": self.size,
             "crop_pct": self.crop_pct,
         }





@require_torch
@require_vision
class      __SCREAMING_SNAKE_CASE					(__A       ,					unittest.TestCase					):


  """simple docstring"""


  _a     :   int			 =    ConvNextImageProcessor if is_vision_available() else None







  def       _a					( self  ):






         """simple docstring"""


         a_	    = ConvNextImageProcessingTester(self  )







  @property
  def       _a					( self  ):






         """simple docstring"""


         return self.image_processor_tester.prepare_image_processor_dict()







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.image_processing_class(**self.image_processor_dict  )
         self.assertTrue(hasattr(UpperCamelCase__      ,  'do_resize'  )  )
         self.assertTrue(hasattr(UpperCamelCase__      ,  'size'  )  )
         self.assertTrue(hasattr(UpperCamelCase__      ,  'crop_pct'  )  )
         self.assertTrue(hasattr(UpperCamelCase__      ,  'do_normalize'  )  )
         self.assertTrue(hasattr(UpperCamelCase__      ,  'image_mean'  )  )
         self.assertTrue(hasattr(UpperCamelCase__      ,  'image_std'  )  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.image_processing_class.from_dict(self.image_processor_dict  )
         self.assertEqual(image_processor.size      ,  {'shortest_edge': 20}  )

         a_	    = self.image_processing_class.from_dict(self.image_processor_dict      ,  size=42  )
         self.assertEqual(image_processor.size      ,  {'shortest_edge': 42}  )







  def       _a					( self  ):






         """simple docstring"""


         pass







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.image_processing_class(**self.image_processor_dict  )
         # create random PIL images
         a_	    = prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase__  )
         for image in image_inputs:
                self.assertIsInstance(UpperCamelCase__      ,  Image.Image  )

         # Test not batched input
         a_	    = image_processing(image_inputs[0]      ,  return_tensors='pt'  ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,  (
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['shortest_edge'],
                 self.image_processor_tester.size['shortest_edge'],
             )      ,  )

         # Test batched
         a_	    = image_processing(UpperCamelCase__      ,  return_tensors='pt'  ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,  (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['shortest_edge'],
                 self.image_processor_tester.size['shortest_edge'],
             )      ,  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.image_processing_class(**self.image_processor_dict  )
         # create random numpy tensors
         a_	    = prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase__      ,  numpify=UpperCamelCase__  )
         for image in image_inputs:
                self.assertIsInstance(UpperCamelCase__      ,  np.ndarray  )

         # Test not batched input
         a_	    = image_processing(image_inputs[0]      ,  return_tensors='pt'  ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,  (
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['shortest_edge'],
                 self.image_processor_tester.size['shortest_edge'],
             )      ,  )

         # Test batched
         a_	    = image_processing(UpperCamelCase__      ,  return_tensors='pt'  ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,  (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['shortest_edge'],
                 self.image_processor_tester.size['shortest_edge'],
             )      ,  )







  def       _a					( self  ):






         """simple docstring"""


         a_	    = self.image_processing_class(**self.image_processor_dict  )
         # create random PyTorch tensors
         a_	    = prepare_image_inputs(self.image_processor_tester      ,  equal_resolution=UpperCamelCase__      ,  torchify=UpperCamelCase__  )
         for image in image_inputs:
                self.assertIsInstance(UpperCamelCase__      ,  torch.Tensor  )

         # Test not batched input
         a_	    = image_processing(image_inputs[0]      ,  return_tensors='pt'  ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,  (
                 1,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['shortest_edge'],
                 self.image_processor_tester.size['shortest_edge'],
             )      ,  )

         # Test batched
         a_	    = image_processing(UpperCamelCase__      ,  return_tensors='pt'  ).pixel_values
         self.assertEqual(
             encoded_images.shape      ,  (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 self.image_processor_tester.size['shortest_edge'],
                 self.image_processor_tester.size['shortest_edge'],
             )      ,  )












'''simple docstring'''







from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowerCAmelCase					   =       logging.get_logger(__name__)

__lowerCAmelCase					   =       {
    "uw-madison/nystromformer-512": "https://huggingface.co/uw-madison/nystromformer-512/resolve/main/config.json",
    # See all Nystromformer models at https://huggingface.co/models?filter=nystromformer
}




class      __SCREAMING_SNAKE_CASE					(__A					):


  """simple docstring"""


  _a     :   Union[str, Any]			 =    '''nystromformer'''







  def __init__( self      ,  UpperCamelCase__=30_000      ,  UpperCamelCase__=768      ,  UpperCamelCase__=12      ,  UpperCamelCase__=12      ,  UpperCamelCase__=3_072      ,  UpperCamelCase__="gelu_new"      ,  UpperCamelCase__=0.1      ,  UpperCamelCase__=0.1      ,  UpperCamelCase__=510      ,  UpperCamelCase__=2      ,  UpperCamelCase__=64      ,  UpperCamelCase__=64      ,  UpperCamelCase__=65      ,  UpperCamelCase__=False      ,  UpperCamelCase__=0.02      ,  UpperCamelCase__=1e-5      ,  UpperCamelCase__=1      ,  UpperCamelCase__=0      ,  UpperCamelCase__=2      ,  **UpperCamelCase__      ,  ):






         """simple docstring"""


         a_	    = vocab_size
         a_	    = max_position_embeddings
         a_	    = hidden_size
         a_	    = num_hidden_layers
         a_	    = num_attention_heads
         a_	    = intermediate_size
         a_	    = hidden_act
         a_	    = hidden_dropout_prob
         a_	    = attention_probs_dropout_prob
         a_	    = initializer_range
         a_	    = type_vocab_size
         a_	    = segment_means_seq_len
         a_	    = num_landmarks
         a_	    = conv_kernel_size
         a_	    = inv_coeff_init_option
         a_	    = layer_norm_eps
         super().__init__(pad_token_id=UpperCamelCase__      ,  bos_token_id=UpperCamelCase__      ,  eos_token_id=UpperCamelCase__      ,  **UpperCamelCase__  )




