code: 
  
  
  
  
  
  from ...configuration_utils import PretrainedConfig
  from ...utils import logging
  
  
  lowerCAmelCase_   =   logging.get_logger(__name__)
  
  lowerCAmelCase_   =   {
      'facebook/opt-125m': 'https://huggingface.co/facebook/opt-125m/blob/main/config.json',
      'facebook/opt-350m': 'https://huggingface.co/facebook/opt-350m/blob/main/config.json',
      'facebook/opt-1.3b': 'https://huggingface.co/facebook/opt-1.3b/blob/main/config.json',
      'facebook/opt-2.7b': 'https://huggingface.co/facebook/opt-2.7b/blob/main/config.json',
      'facebook/opt-6.7b': 'https://huggingface.co/facebook/opt-6.7b/blob/main/config.json',
      'facebook/opt-13b': 'https://huggingface.co/facebook/opt-13b/blob/main/config.json',
  }
  
  class 				A    (UpperCAmelCase_				):
        _SCREAMING_SNAKE_CASE					=							"""opt"""
        _SCREAMING_SNAKE_CASE					=							["""past_key_values"""]
  
  
  
        def __init__(					self     ,  lowercase_=5_0272     ,  lowercase_=768     ,  lowercase_=12     ,  lowercase_=3072     ,  lowercase_=2048     ,  lowercase_=True     ,  lowercase_=False     ,  lowercase_=None     ,  lowercase_=0.1     ,  lowercase_=0.0     ,  lowercase_=12     ,  lowercase_="relu"     ,  lowercase_=0.0     ,  lowercase_=0.02     ,  lowercase_=True     ,  lowercase_=1     ,  lowercase_=2     ,  lowercase_=2     ,  lowercase_=True     ,  lowercase_=True     ,  **lowercase_     ,  )      ->   Dict:
  
  
  
               '''simple docstring'''
  
               super().__init__(
                   pad_token_id=__UpperCamelCase     ,  bos_token_id=__UpperCamelCase     ,  eos_token_id=__UpperCamelCase     ,  **__UpperCamelCase     ,  )
               _snake_case      :							int     				=						vocab_size
               _snake_case      :							Tuple     				=						max_position_embeddings
               _snake_case      :							Optional[Any]     				=						num_attention_heads
               _snake_case      :							Optional[int]     				=						word_embed_proj_dim if word_embed_proj_dim is not None else hidden_size
               _snake_case      :							str     				=						ffn_dim
               _snake_case      :							List[str]     				=						hidden_size
               _snake_case      :							int     				=						num_hidden_layers
               _snake_case      :							Dict     				=						dropout
               _snake_case      :							Any     				=						attention_dropout
               _snake_case      :							int     				=						activation_function
               _snake_case      :							int     				=						init_std
               _snake_case      :							Dict     				=						layerdrop
               _snake_case      :							List[Any]     				=						use_cache
               _snake_case      :							Optional[Any]     				=						do_layer_norm_before
               # We keep these variables at `True` for backward compatibility.
               _snake_case      :							str     				=						enable_bias
               _snake_case      :							Tuple     				=						layer_norm_elementwise_affine
  
               # Note that the only purpose of `_remove_final_layer_norm` is to keep backward compatibility
               # with checkpoints that have been fine-tuned before transformers v4.20.1
               # see https://github.com/facebookresearch/metaseq/pull/164
               _snake_case      :							int     				=						_remove_final_layer_norm
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  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 				A    (unittest.TestCase				):
  
  
  
        def __init__(					self     ,  lowercase_     ,  lowercase_=7     ,  lowercase_=3     ,  lowercase_=18     ,  lowercase_=30     ,  lowercase_=400     ,  lowercase_=True     ,  lowercase_=None     ,  lowercase_=0.875     ,  lowercase_=True     ,  lowercase_=[0.5, 0.5, 0.5]     ,  lowercase_=[0.5, 0.5, 0.5]     ,  )      ->   List[str]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Tuple     				=						size if size is not None else {'''shortest_edge''': 20}
               _snake_case      :							List[Any]     				=						parent
               _snake_case      :							Optional[int]     				=						batch_size
               _snake_case      :							str     				=						num_channels
               _snake_case      :							Union[str, Any]     				=						image_size
               _snake_case      :							Optional[Any]     				=						min_resolution
               _snake_case      :							Union[str, Any]     				=						max_resolution
               _snake_case      :							Tuple     				=						do_resize
               _snake_case      :							List[Any]     				=						size
               _snake_case      :							Optional[int]     				=						crop_pct
               _snake_case      :							Any     				=						do_normalize
               _snake_case      :							Optional[int]     				=						image_mean
               _snake_case      :							Union[str, Any]     				=						image_std
  
  
  
        def    __a (					self					)      ->   str:
  
  
  
               '''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 				A    (__UpperCAmelCase       ,unittest.TestCase				):
        _SCREAMING_SNAKE_CASE					=							ConvNextImageProcessor if is_vision_available() else None
  
  
  
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[Any]     				=						ConvNextImageProcessingTester(self					)
  
  
  
        @property
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
        def    __a (					self					)      ->   str:
  
  
  
               '''simple docstring'''
  
               _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_     ,  '''crop_pct'''					)					)
               self.assertTrue(hasattr(lowercase_     ,  '''do_normalize'''					)					)
               self.assertTrue(hasattr(lowercase_     ,  '''image_mean'''					)					)
               self.assertTrue(hasattr(lowercase_     ,  '''image_std'''					)					)
  
  
  
        def    __a (					self					)      ->   List[Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							int     				=						self.image_processing_class.from_dict(self.image_processor_dict					)
               self.assertEqual(image_processor.size     ,  {'''shortest_edge''': 20}					)
  
               _snake_case      :							Tuple     				=						self.image_processing_class.from_dict(self.image_processor_dict     ,  size=42					)
               self.assertEqual(image_processor.size     ,  {'''shortest_edge''': 42}					)
  
  
  
        def    __a (					self					)      ->   List[Any]:
  
  
  
               '''simple docstring'''
  
               pass
  
  
  
        def    __a (					self					)      ->   int:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Tuple     				=						self.image_processing_class(**self.image_processor_dict					)
               # create random PIL images
               _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
               _snake_case      :							List[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.size['''shortest_edge'''],
                       self.image_processor_tester.size['''shortest_edge'''],
                   )     ,  )
  
               # Test batched
               _snake_case      :							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.size['''shortest_edge'''],
                       self.image_processor_tester.size['''shortest_edge'''],
                   )     ,  )
  
  
  
        def    __a (					self					)      ->   Dict:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Tuple     				=						self.image_processing_class(**self.image_processor_dict					)
               # create random numpy tensors
               _snake_case      :							Tuple     				=						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
               _snake_case      :							List[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.size['''shortest_edge'''],
                       self.image_processor_tester.size['''shortest_edge'''],
                   )     ,  )
  
               # Test batched
               _snake_case      :							Union[str, 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.size['''shortest_edge'''],
                       self.image_processor_tester.size['''shortest_edge'''],
                   )     ,  )
  
  
  
        def    __a (					self					)      ->   Union[str, Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Union[str, Any]     				=						self.image_processing_class(**self.image_processor_dict					)
               # create random PyTorch tensors
               _snake_case      :							Dict     				=						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
               _snake_case      :							Union[str, Any]     				=						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
               _snake_case      :							List[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.size['''shortest_edge'''],
                       self.image_processor_tester.size['''shortest_edge'''],
                   )     ,  )
  
  
  
  
  
  
  