






'''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 MobileViTImageProcessor






class      __SCREAMING_SNAKE_CASE      (			unittest.TestCase				):




 def __init__(      self	:							Any					,      __lowercase	:							Dict					,      __lowercase	:							Optional[int]=7					,      __lowercase	:							Dict=3					,      __lowercase	:							Optional[Any]=18					,      __lowercase	:							int=30					,      __lowercase	:							Dict=4_00					,      __lowercase	:							Any=True					,      __lowercase	:							Optional[Any]=None					,      __lowercase	:							Optional[int]=True					,      __lowercase	:							Optional[int]=None					,      __lowercase	:							str=True					,      )	->						str:
       SCREAMING_SNAKE_CASE__     :				List[Any]									=size if size is not None else {'''shortest_edge''': 20}
       SCREAMING_SNAKE_CASE__     :				Optional[Any]									=crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
       SCREAMING_SNAKE_CASE__     :				List[Any]									=parent
       SCREAMING_SNAKE_CASE__     :				int									=batch_size
       SCREAMING_SNAKE_CASE__     :				Any									=num_channels
       SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=image_size
       SCREAMING_SNAKE_CASE__     :				List[str]									=min_resolution
       SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=max_resolution
       SCREAMING_SNAKE_CASE__     :				Tuple									=do_resize
       SCREAMING_SNAKE_CASE__     :				str									=size
       SCREAMING_SNAKE_CASE__     :				int									=do_center_crop
       SCREAMING_SNAKE_CASE__     :				str									=crop_size
       SCREAMING_SNAKE_CASE__     :				Optional[int]									=do_flip_channel_order




 def      __magic_name__	(      self	:							str      )	->						int:
       return {
           "do_resize": self.do_resize,
           "size": self.size,
           "do_center_crop": self.do_center_crop,
           "crop_size": self.crop_size,
           "do_flip_channel_order": self.do_flip_channel_order,
       }






@require_torch
@require_vision
class      __SCREAMING_SNAKE_CASE      (			lowerCamelCase	,				unittest.TestCase				):
 snake_case_  							=							MobileViTImageProcessor if is_vision_available() else None




 def      __magic_name__	(      self	:							Union[str, Any]      )	->						List[Any]:
       SCREAMING_SNAKE_CASE__     :				List[Any]									=MobileViTImageProcessingTester(self      )




 @property
 def      __magic_name__	(      self	:							Union[str, Any]      )	->						int:
       return self.image_processor_tester.prepare_image_processor_dict()




 def      __magic_name__	(      self	:							List[Any]      )	->						Optional[int]:
       SCREAMING_SNAKE_CASE__     :				List[Any]									=self.image_processing_class(**self.image_processor_dict      )
       self.assertTrue(hasattr(__lowercase					,      '''do_resize'''      )      )
       self.assertTrue(hasattr(__lowercase					,      '''size'''      )      )
       self.assertTrue(hasattr(__lowercase					,      '''do_center_crop'''      )      )
       self.assertTrue(hasattr(__lowercase					,      '''center_crop'''      )      )
       self.assertTrue(hasattr(__lowercase					,      '''do_flip_channel_order'''      )      )




 def      __magic_name__	(      self	:							Tuple      )	->						Union[str, Any]:
       SCREAMING_SNAKE_CASE__     :				int									=self.image_processing_class.from_dict(self.image_processor_dict      )
       self.assertEqual(image_processor.size					,      {'''shortest_edge''': 20}      )
       self.assertEqual(image_processor.crop_size					,      {'''height''': 18, '''width''': 18}      )

       SCREAMING_SNAKE_CASE__     :				List[Any]									=self.image_processing_class.from_dict(self.image_processor_dict					,      size=42					,      crop_size=84      )
       self.assertEqual(image_processor.size					,      {'''shortest_edge''': 42}      )
       self.assertEqual(image_processor.crop_size					,      {'''height''': 84, '''width''': 84}      )




 def      __magic_name__	(      self	:							List[Any]      )	->						Union[str, Any]:
       pass




 def      __magic_name__	(      self	:							Any      )	->						Optional[Any]:
       # Initialize image_processing
       SCREAMING_SNAKE_CASE__     :				Any									=self.image_processing_class(**self.image_processor_dict      )
       # create random PIL images
       SCREAMING_SNAKE_CASE__     :				List[str]									=prepare_image_inputs(self.image_processor_tester					,      equal_resolution=__lowercase      )
       for image in image_inputs:
             self.assertIsInstance(__lowercase					,      Image.Image      )

       # Test not batched input
       SCREAMING_SNAKE_CASE__     :				str									=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.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           )					,      )

       # Test batched
       SCREAMING_SNAKE_CASE__     :				Optional[int]									=image_processing(__lowercase					,      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.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           )					,      )




 def      __magic_name__	(      self	:							Dict      )	->						List[Any]:
       # Initialize image_processing
       SCREAMING_SNAKE_CASE__     :				Dict									=self.image_processing_class(**self.image_processor_dict      )
       # create random numpy tensors
       SCREAMING_SNAKE_CASE__     :				Optional[Any]									=prepare_image_inputs(self.image_processor_tester					,      equal_resolution=__lowercase					,      numpify=__lowercase      )
       for image in image_inputs:
             self.assertIsInstance(__lowercase					,      np.ndarray      )

       # Test not batched input
       SCREAMING_SNAKE_CASE__     :				Optional[int]									=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.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           )					,      )

       # Test batched
       SCREAMING_SNAKE_CASE__     :				Optional[int]									=image_processing(__lowercase					,      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.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           )					,      )




 def      __magic_name__	(      self	:							str      )	->						Dict:
       # Initialize image_processing
       SCREAMING_SNAKE_CASE__     :				Optional[int]									=self.image_processing_class(**self.image_processor_dict      )
       # create random PyTorch tensors
       SCREAMING_SNAKE_CASE__     :				str									=prepare_image_inputs(self.image_processor_tester					,      equal_resolution=__lowercase					,      torchify=__lowercase      )
       for image in image_inputs:
             self.assertIsInstance(__lowercase					,      torch.Tensor      )

       # Test not batched input
       SCREAMING_SNAKE_CASE__     :				str									=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.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           )					,      )

       # Test batched
       SCREAMING_SNAKE_CASE__     :				Any									=image_processing(__lowercase					,      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.crop_size['''height'''],
               self.image_processor_tester.crop_size['''width'''],
           )					,      )







'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


a_					= logging.get_logger(__name__)

a_					= {
    'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json',
}






class      __SCREAMING_SNAKE_CASE      (			lowerCamelCase				):
 snake_case_  							=							"""gpt_bigcode"""
 snake_case_  							=							["""past_key_values"""]
 snake_case_  							=							{
     """hidden_size""": """n_embd""",
     """max_position_embeddings""": """n_positions""",
     """num_attention_heads""": """n_head""",
     """num_hidden_layers""": """n_layer""",
 }




 def __init__(      self	:							Any					,      __lowercase	:							Any=5_02_57					,      __lowercase	:							int=10_24					,      __lowercase	:							List[str]=7_68					,      __lowercase	:							Optional[int]=12					,      __lowercase	:							Dict=12					,      __lowercase	:							List[str]=None					,      __lowercase	:							int="gelu_pytorch_tanh"					,      __lowercase	:							Union[str, Any]=0.1					,      __lowercase	:							Optional[int]=0.1					,      __lowercase	:							Optional[int]=0.1					,      __lowercase	:							Optional[Any]=1e-5					,      __lowercase	:							List[str]=0.02					,      __lowercase	:							Tuple=True					,      __lowercase	:							Optional[Any]=True					,      __lowercase	:							Union[str, Any]=5_02_56					,      __lowercase	:							List[Any]=5_02_56					,      __lowercase	:							Union[str, Any]=True					,      __lowercase	:							List[str]=True					,      __lowercase	:							Dict=True					,      **__lowercase	:							List[Any]					,      )	->						Optional[int]:
       SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=vocab_size
       SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=n_positions
       SCREAMING_SNAKE_CASE__     :				Dict									=n_embd
       SCREAMING_SNAKE_CASE__     :				Dict									=n_layer
       SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=n_head
       SCREAMING_SNAKE_CASE__     :				List[str]									=n_inner
       SCREAMING_SNAKE_CASE__     :				List[str]									=activation_function
       SCREAMING_SNAKE_CASE__     :				List[Any]									=resid_pdrop
       SCREAMING_SNAKE_CASE__     :				List[Any]									=embd_pdrop
       SCREAMING_SNAKE_CASE__     :				List[str]									=attn_pdrop
       SCREAMING_SNAKE_CASE__     :				Dict									=layer_norm_epsilon
       SCREAMING_SNAKE_CASE__     :				List[str]									=initializer_range
       SCREAMING_SNAKE_CASE__     :				List[Any]									=scale_attn_weights
       SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=use_cache
       SCREAMING_SNAKE_CASE__     :				Dict									=attention_softmax_in_fpaa
       SCREAMING_SNAKE_CASE__     :				int									=scale_attention_softmax_in_fpaa
       SCREAMING_SNAKE_CASE__     :				Dict									=multi_query

       SCREAMING_SNAKE_CASE__     :				Optional[Any]									=bos_token_id
       SCREAMING_SNAKE_CASE__     :				Optional[Any]									=eos_token_id

       super().__init__(bos_token_id=__lowercase					,      eos_token_id=__lowercase					,      **__lowercase      )