code: 
  
  
  
  
  
  
  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 ViltImageProcessor
  
  class 					snake_case_							(       unittest.TestCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     def __init__(    self:	Union[str, Any]   ,       snake_case__:	str   ,       snake_case__:	Optional[Any]=7   ,       snake_case__:	Any=3   ,       snake_case__:	int=18   ,       snake_case__:	Union[str, Any]=30   ,       snake_case__:	Union[str, Any]=400   ,       snake_case__:	Optional[int]=True   ,       snake_case__:	Union[str, Any]=None   ,       snake_case__:	Union[str, Any]=2   ,       snake_case__:	Optional[int]=True   ,       snake_case__:	Tuple=[0.5, 0.5, 0.5]   ,       snake_case__:	Any=[0.5, 0.5, 0.5]   ,       )  ->		List[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	size if size is not None else {'shortest_edge': 30}
         _lowercase     =	parent
         _lowercase     =	batch_size
         _lowercase     =	num_channels
         _lowercase     =	image_size
         _lowercase     =	min_resolution
         _lowercase     =	max_resolution
         _lowercase     =	do_resize
         _lowercase     =	size
         _lowercase     =	size_divisor
         _lowercase     =	do_normalize
         _lowercase     =	image_mean
         _lowercase     =	image_std
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]	)  ->		Union[str, Any]:
  
  
         """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,
             "size_divisor": self.size_divisor,
         }
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict   ,       snake_case__:	Tuple   ,       snake_case__:	List[str]=False	)  ->		Optional[Any]:
  
  
         """simple docstring"""
  
  
  
         if not batched:
             _lowercase     =	self.size['shortest_edge']
             _lowercase     =	image_inputs[0]
             if isinstance(UpperCAmelCase_   ,       Image.Image	):
                 _lowercase     =	image.size
             else:
                 _lowercase     =	image.shape[1], image.shape[2]
             _lowercase     =	size / min(UpperCAmelCase_   ,       UpperCAmelCase_	)
             if h < w:
                 _lowercase     =	size, scale * w
             else:
                 _lowercase     =	scale * h, size
  
             _lowercase     =	int((1_333 / 800) * size	)
             if max(UpperCAmelCase_   ,       UpperCAmelCase_	) > max_size:
                 _lowercase     =	max_size / max(UpperCAmelCase_   ,       UpperCAmelCase_	)
                 _lowercase     =	newh * scale
                 _lowercase     =	neww * scale
  
             _lowercase     =	int(newh + 0.5	), int(neww + 0.5	)
             _lowercase     =	(
                 newh // self.size_divisor * self.size_divisor,
                 neww // self.size_divisor * self.size_divisor,
             )
  
         else:
             _lowercase     =	[]
             for image in image_inputs:
                 _lowercase     =	self.get_expected_values([image]	)
                 expected_values.append((expected_height, expected_width)	)
             _lowercase     =	max(UpperCAmelCase_   ,       key=lambda snake_case__	: item[0]	)[0]
             _lowercase     =	max(UpperCAmelCase_   ,       key=lambda snake_case__	: item[1]	)[1]
  
         return expected_height, expected_width
  
  
  
  
  
  
  @require_torch
  @require_vision
  class 					snake_case_							(       lowercase_      ,			unittest.TestCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						ViltImageProcessor if is_vision_available() else None
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	str	)  ->		Any:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	ViltImageProcessingTester(self	)
  
     @property
     def 			SCREAMING_SNAKE_CASE__				(    self:	Union[str, Any]	)  ->		Union[str, Any]:
  
  
         """simple docstring"""
  
  
  
         return self.image_processor_tester.prepare_image_processor_dict()
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[str]	)  ->		Optional[int]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.image_processing_class(**self.image_processor_dict	)
         self.assertTrue(hasattr(UpperCAmelCase_   ,       'image_mean'	)	)
         self.assertTrue(hasattr(UpperCAmelCase_   ,       'image_std'	)	)
         self.assertTrue(hasattr(UpperCAmelCase_   ,       'do_normalize'	)	)
         self.assertTrue(hasattr(UpperCAmelCase_   ,       'do_resize'	)	)
         self.assertTrue(hasattr(UpperCAmelCase_   ,       'size'	)	)
         self.assertTrue(hasattr(UpperCAmelCase_   ,       'size_divisor'	)	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[str]	)  ->		List[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.image_processing_class.from_dict(self.image_processor_dict	)
         self.assertEqual(image_processor.size   ,       {'shortest_edge': 30}	)
  
         _lowercase     =	self.image_processing_class.from_dict(self.image_processor_dict   ,       size=42	)
         self.assertEqual(image_processor.size   ,       {'shortest_edge': 42}	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict	)  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         pass
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]	)  ->		Any:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.image_processing_class(**self.image_processor_dict	)
         # create random PIL images
         _lowercase     =	prepare_image_inputs(self.image_processor_tester   ,       equal_resolution=UpperCAmelCase_	)
         for image in image_inputs:
             self.assertIsInstance(UpperCAmelCase_   ,       Image.Image	)
  
         # Test not batched input
         _lowercase     =	image_processing(image_inputs[0]   ,       return_tensors='pt'	).pixel_values
  
         _lowercase     =	self.image_processor_tester.get_expected_values(UpperCAmelCase_	)
         self.assertEqual(
             encoded_images.shape   ,       (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,       )
  
         # Test batched
         _lowercase     =	image_processing(UpperCAmelCase_   ,       return_tensors='pt'	).pixel_values
  
         _lowercase     =	self.image_processor_tester.get_expected_values(UpperCAmelCase_   ,       batched=UpperCAmelCase_	)
         self.assertEqual(
             encoded_images.shape   ,       (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 expected_height,
                 expected_width,
             )   ,       )
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]	)  ->		List[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.image_processing_class(**self.image_processor_dict	)
         # create random numpy tensors
         _lowercase     =	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
         _lowercase     =	image_processing(image_inputs[0]   ,       return_tensors='pt'	).pixel_values
  
         _lowercase     =	self.image_processor_tester.get_expected_values(UpperCAmelCase_	)
         self.assertEqual(
             encoded_images.shape   ,       (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,       )
  
         # Test batched
         _lowercase     =	image_processing(UpperCAmelCase_   ,       return_tensors='pt'	).pixel_values
  
         _lowercase     =	self.image_processor_tester.get_expected_values(UpperCAmelCase_   ,       batched=UpperCAmelCase_	)
         self.assertEqual(
             encoded_images.shape   ,       (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 expected_height,
                 expected_width,
             )   ,       )
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[str]	)  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.image_processing_class(**self.image_processor_dict	)
         # create random PyTorch tensors
         _lowercase     =	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
         _lowercase     =	image_processing(image_inputs[0]   ,       return_tensors='pt'	).pixel_values
  
         _lowercase     =	self.image_processor_tester.get_expected_values(UpperCAmelCase_	)
         self.assertEqual(
             encoded_images.shape   ,       (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,       )
  
         # Test batched
         _lowercase     =	image_processing(UpperCAmelCase_   ,       return_tensors='pt'	).pixel_values
  
         _lowercase     =	self.image_processor_tester.get_expected_values(UpperCAmelCase_   ,       batched=UpperCAmelCase_	)
         self.assertEqual(
             encoded_images.shape   ,       (
                 self.image_processor_tester.batch_size,
                 self.image_processor_tester.num_channels,
                 expected_height,
                 expected_width,
             )   ,       )
  
  
  
  
style_context: 
  
  
  
  
  
  
  from typing import List, Union
  
  from ...configuration_utils import PretrainedConfig
  from ...utils import logging
  
  
  lowerCamelCase										=  logging.get_logger(__name__)
  
  lowerCamelCase										=  {
      '''allenai/led-base-16384''': '''https://huggingface.co/allenai/led-base-16384/resolve/main/config.json''',
      # See all LED models at https://huggingface.co/models?filter=led
  }
  
  class 					snake_case_							(       lowercase_      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						"""led"""
     __lowerCAmelCase      =						{
         """num_attention_heads""": """encoder_attention_heads""",
         """hidden_size""": """d_model""",
         """attention_probs_dropout_prob""": """attention_dropout""",
         """initializer_range""": """init_std""",
     }
  
     def __init__(    self:	int   ,       snake_case__:	str=50_265   ,       snake_case__:	Dict=16_384   ,       snake_case__:	str=1_024   ,       snake_case__:	Tuple=12   ,       snake_case__:	int=4_096   ,       snake_case__:	Union[str, Any]=16   ,       snake_case__:	int=12   ,       snake_case__:	Union[str, Any]=4_096   ,       snake_case__:	Optional[Any]=16   ,       snake_case__:	str=0.0   ,       snake_case__:	Optional[Any]=0.0   ,       snake_case__:	List[Any]=True   ,       snake_case__:	List[Any]=True   ,       snake_case__:	List[Any]="gelu"   ,       snake_case__:	Optional[int]=1_024   ,       snake_case__:	List[Any]=0.1   ,       snake_case__:	int=0.0   ,       snake_case__:	List[str]=0.0   ,       snake_case__:	List[str]=0.02   ,       snake_case__:	Dict=2   ,       snake_case__:	int=0.0   ,       snake_case__:	Optional[int]=1   ,       snake_case__:	Tuple=0   ,       snake_case__:	Union[str, Any]=2   ,       snake_case__:	Union[List[int], int] = 512   ,       **snake_case__:	int   ,       )  ->		List[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	vocab_size
         _lowercase     =	max_encoder_position_embeddings
         _lowercase     =	max_decoder_position_embeddings
         _lowercase     =	d_model
         _lowercase     =	encoder_ffn_dim
         _lowercase     =	encoder_layers
         _lowercase     =	encoder_attention_heads
         _lowercase     =	decoder_ffn_dim
         _lowercase     =	decoder_layers
         _lowercase     =	decoder_attention_heads
         _lowercase     =	dropout
         _lowercase     =	attention_dropout
         _lowercase     =	activation_dropout
         _lowercase     =	activation_function
         _lowercase     =	init_std
         _lowercase     =	encoder_layerdrop
         _lowercase     =	decoder_layerdrop
         _lowercase     =	classifier_dropout
         _lowercase     =	use_cache
         _lowercase     =	encoder_layers
         _lowercase     =	attention_window
  
         super().__init__(
             pad_token_id=snake_case__   ,       bos_token_id=snake_case__   ,       eos_token_id=snake_case__   ,       is_encoder_decoder=snake_case__   ,       decoder_start_token_id=snake_case__   ,       **snake_case__   ,       )
  