code: 
  
  
  
  '''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 ViltImageProcessor
  class        UpperCAmelCase__  (    unittest.TestCase):
  
  
  
   def __init__(  self		,	lowercase		,	lowercase=7		,	lowercase=3		,	lowercase=1_8		,	lowercase=3_0		,	lowercase=4_0_0		,	lowercase=True		,	lowercase=None		,	lowercase=2		,	lowercase=True		,	lowercase=[0.5, 0.5, 0.5]		,	lowercase=[0.5, 0.5, 0.5]		,	)  ->							List[str]:
    __UpperCamelCase				      =  size if size is not None else {"""shortest_edge""": 3_0}
    __UpperCamelCase				      =  parent
    __UpperCamelCase				      =  batch_size
    __UpperCamelCase				      =  num_channels
    __UpperCamelCase				      =  image_size
    __UpperCamelCase				      =  min_resolution
    __UpperCamelCase				      =  max_resolution
    __UpperCamelCase				      =  do_resize
    __UpperCamelCase				      =  size
    __UpperCamelCase				      =  size_divisor
    __UpperCamelCase				      =  do_normalize
    __UpperCamelCase				      =  image_mean
    __UpperCamelCase				      =  image_std
  
  
  
   def    __lowerCamelCase				(  self			)  ->							List[str]:
    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    __lowerCamelCase				(  self		,	lowercase		,	lowercase=False			)  ->							Union[str, Any]:
    if not batched:
     __UpperCamelCase				      =  self.size["""shortest_edge"""]
     __UpperCamelCase				      =  image_inputs[0]
     if isinstance(lowercase		,	Image.Image			):
      __UpperCamelCase      ,		__UpperCamelCase				      =  image.size
     else:
      __UpperCamelCase      ,		__UpperCamelCase				      =  image.shape[1], image.shape[2]
     __UpperCamelCase				      =  size / min(lowercase		,	lowercase			)
     if h < w:
      __UpperCamelCase      ,		__UpperCamelCase				      =  size, scale * w
     else:
      __UpperCamelCase      ,		__UpperCamelCase				      =  scale * h, size
  
     __UpperCamelCase				      =  int((1_3_3_3 / 8_0_0) * size			)
     if max(lowercase		,	lowercase			) > max_size:
      __UpperCamelCase				      =  max_size / max(lowercase		,	lowercase			)
      __UpperCamelCase				      =  newh * scale
      __UpperCamelCase				      =  neww * scale
  
     __UpperCamelCase      ,		__UpperCamelCase				      =  int(newh + 0.5			), int(neww + 0.5			)
     __UpperCamelCase      ,		__UpperCamelCase				      =  (
         newh // self.size_divisor * self.size_divisor,
         neww // self.size_divisor * self.size_divisor,
     )
  
    else:
     __UpperCamelCase				      =  []
     for image in image_inputs:
      __UpperCamelCase      ,		__UpperCamelCase				      =  self.get_expected_values([image]			)
      expected_values.append((expected_height, expected_width)			)
     __UpperCamelCase				      =  max(lowercase		,	key=lambda lowercase			: item[0]			)[0]
     __UpperCamelCase				      =  max(lowercase		,	key=lambda lowercase			: item[1]			)[1]
  
    return expected_height, expected_width
  
  
  @require_torch
  @require_vision
  class        UpperCAmelCase__  (    UpperCAmelCase_							,		unittest.TestCase):
   __SCREAMING_SNAKE_CASE					      =				ViltImageProcessor if is_vision_available() else None
  
  
  
   def    __lowerCamelCase				(  self			)  ->							Any:
    __UpperCamelCase				      =  ViltImageProcessingTester(self			)
  
  
  
   @property
   def    __lowerCamelCase				(  self			)  ->							int:
    return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
   def    __lowerCamelCase				(  self			)  ->							Optional[Any]:
    __UpperCamelCase				      =  self.image_processing_class(**self.image_processor_dict			)
    self.assertTrue(hasattr(lowercase		,	"""image_mean"""			)			)
    self.assertTrue(hasattr(lowercase		,	"""image_std"""			)			)
    self.assertTrue(hasattr(lowercase		,	"""do_normalize"""			)			)
    self.assertTrue(hasattr(lowercase		,	"""do_resize"""			)			)
    self.assertTrue(hasattr(lowercase		,	"""size"""			)			)
    self.assertTrue(hasattr(lowercase		,	"""size_divisor"""			)			)
  
  
  
   def    __lowerCamelCase				(  self			)  ->							Optional[Any]:
    __UpperCamelCase				      =  self.image_processing_class.from_dict(self.image_processor_dict			)
    self.assertEqual(image_processor.size		,	{"""shortest_edge""": 3_0}			)
  
    __UpperCamelCase				      =  self.image_processing_class.from_dict(self.image_processor_dict		,	size=4_2			)
    self.assertEqual(image_processor.size		,	{"""shortest_edge""": 4_2}			)
  
  
  
   def    __lowerCamelCase				(  self			)  ->							Optional[int]:
    pass
  
  
  
   def    __lowerCamelCase				(  self			)  ->							Union[str, Any]:
    # Initialize image_processing
    __UpperCamelCase				      =  self.image_processing_class(**self.image_processor_dict			)
    # create random PIL images
    __UpperCamelCase				      =  prepare_image_inputs(self.image_processor_tester		,	equal_resolution=lowercase			)
    for image in image_inputs:
     self.assertIsInstance(lowercase		,	Image.Image			)
  
    # Test not batched input
    __UpperCamelCase				      =  image_processing(image_inputs[0]		,	return_tensors="""pt"""			).pixel_values
  
    __UpperCamelCase      ,		__UpperCamelCase				      =  self.image_processor_tester.get_expected_values(lowercase			)
    self.assertEqual(
        encoded_images.shape		,	(1, self.image_processor_tester.num_channels, expected_height, expected_width)		,	)
  
    # Test batched
    __UpperCamelCase				      =  image_processing(lowercase		,	return_tensors="""pt"""			).pixel_values
  
    __UpperCamelCase      ,		__UpperCamelCase				      =  self.image_processor_tester.get_expected_values(lowercase		,	batched=lowercase			)
    self.assertEqual(
        encoded_images.shape		,	(
            self.image_processor_tester.batch_size,
            self.image_processor_tester.num_channels,
            expected_height,
            expected_width,
        )		,	)
  
  
  
   def    __lowerCamelCase				(  self			)  ->							Union[str, Any]:
    # Initialize image_processing
    __UpperCamelCase				      =  self.image_processing_class(**self.image_processor_dict			)
    # create random numpy tensors
    __UpperCamelCase				      =  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
    __UpperCamelCase				      =  image_processing(image_inputs[0]		,	return_tensors="""pt"""			).pixel_values
  
    __UpperCamelCase      ,		__UpperCamelCase				      =  self.image_processor_tester.get_expected_values(lowercase			)
    self.assertEqual(
        encoded_images.shape		,	(1, self.image_processor_tester.num_channels, expected_height, expected_width)		,	)
  
    # Test batched
    __UpperCamelCase				      =  image_processing(lowercase		,	return_tensors="""pt"""			).pixel_values
  
    __UpperCamelCase      ,		__UpperCamelCase				      =  self.image_processor_tester.get_expected_values(lowercase		,	batched=lowercase			)
    self.assertEqual(
        encoded_images.shape		,	(
            self.image_processor_tester.batch_size,
            self.image_processor_tester.num_channels,
            expected_height,
            expected_width,
        )		,	)
  
  
  
  
   def    __lowerCamelCase				(  self			)  ->							str:
    # Initialize image_processing
    __UpperCamelCase				      =  self.image_processing_class(**self.image_processor_dict			)
    # create random PyTorch tensors
    __UpperCamelCase				      =  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
    __UpperCamelCase				      =  image_processing(image_inputs[0]		,	return_tensors="""pt"""			).pixel_values
  
    __UpperCamelCase      ,		__UpperCamelCase				      =  self.image_processor_tester.get_expected_values(lowercase			)
    self.assertEqual(
        encoded_images.shape		,	(1, self.image_processor_tester.num_channels, expected_height, expected_width)		,	)
  
    # Test batched
    __UpperCamelCase				      =  image_processing(lowercase		,	return_tensors="""pt"""			).pixel_values
  
    __UpperCamelCase      ,		__UpperCamelCase				      =  self.image_processor_tester.get_expected_values(lowercase		,	batched=lowercase			)
    self.assertEqual(
        encoded_images.shape		,	(
            self.image_processor_tester.batch_size,
            self.image_processor_tester.num_channels,
            expected_height,
            expected_width,
        )		,	)
  
  
  
  
  
  
style_context: 
  
  
  
  '''simple docstring'''
  
  
  
  import argparse
  
  from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta
  from transformers.utils import logging
  
  
  logging.set_verbosity_info()
  
  
  
  
  
  
  
  def _lowercase   (  __A							,__A							,__A       ):
  
  
  
   '''simple docstring'''
  
  
  
   __UpperCamelCase				      =  TaConfig.from_json_file(__A       )
   print(f"Building PyTorch model from configuration: {config}"       )
   __UpperCamelCase				      =  TaForConditionalGeneration(__A       )
  
   # Load weights from tf checkpoint
   load_tf_weights_in_ta(__A							,__A							,__A       )
  
   # Save pytorch-model
   print(f"Save PyTorch model to {pytorch_dump_path}"       )
   model.save_pretrained(__A       )
  
  
  if __name__ == "__main__":
   a__						:			int										=			argparse.ArgumentParser()
   # Required parameters
   parser.add_argument(
       '--tf_checkpoint_path', default=None, type=str, required=True, help='Path to the TensorFlow checkpoint path.'
   )
   parser.add_argument(
       '--config_file',
       default=None,
       type=str,
       required=True,
       help=(
           'The config json file corresponding to the pre-trained T5 model. \nThis specifies the model architecture.'
       ),
   )
   parser.add_argument(
       '--pytorch_dump_path', default=None, type=str, required=True, help='Path to the output PyTorch model.'
   )
   a__						:			Optional[Any]										=			parser.parse_args()
   convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)
  
  
  
  
  
  