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 OwlViTImageProcessor
  
  
  
  
  
  class   lowerCamelCase_							( unittest.TestCase							):
  
  
  
  
  					'''simple docstring'''
  
  
  
  
  
  
  					def __init__(					self,						__UpperCamelCase,						__UpperCamelCase=7,						__UpperCamelCase=3,						__UpperCamelCase=18,						__UpperCamelCase=30,						__UpperCamelCase=400,						__UpperCamelCase=True,						__UpperCamelCase=None,						__UpperCamelCase=True,						__UpperCamelCase=None,						__UpperCamelCase=True,						__UpperCamelCase=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73],						__UpperCamelCase=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11],						__UpperCamelCase=True,						):
  							_snake_case			 = parent
  							_snake_case			 = batch_size
  							_snake_case			 = num_channels
  							_snake_case			 = image_size
  							_snake_case			 = min_resolution
  							_snake_case			 = max_resolution
  							_snake_case			 = do_resize
  							_snake_case			 = size if size is not None else {"height": 18, "width": 18}
  							_snake_case			 = do_center_crop
  							_snake_case			 = crop_size if crop_size is not None else {"height": 18, "width": 18}
  							_snake_case			 = do_normalize
  							_snake_case			 = image_mean
  							_snake_case			 = image_std
  							_snake_case			 = do_convert_rgb
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							return {
  							    "do_resize": self.do_resize,
  							    "size": self.size,
  							    "do_center_crop": self.do_center_crop,
  							    "crop_size": self.crop_size,
  							    "do_normalize": self.do_normalize,
  							    "image_mean": self.image_mean,
  							    "image_std": self.image_std,
  							    "do_convert_rgb": self.do_convert_rgb,
  							}
  
  
  
  
  
  @require_torch
  @require_vision
  class   lowerCamelCase_							( UpperCAmelCase_, unittest.TestCase							):
  
  
  
  
  					'''simple docstring'''
  
  
  
  
  
  
  					lowercase__					=				OwlViTImageProcessor if is_vision_available() else None
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							_snake_case			 = OwlViTImageProcessingTester(self				)
  
  
  
  
  
  
  					@property
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							_snake_case			 = self.image_processing_class(**self.image_processor_dict				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"do_resize"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"size"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"do_center_crop"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"center_crop"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"do_normalize"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"image_mean"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"image_std"				)				)
  							self.assertTrue(hasattr(__UpperCamelCase,						"do_convert_rgb"				)				)
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							_snake_case			 = self.image_processing_class.from_dict(self.image_processor_dict				)
  							self.assertEqual(image_processor.size,						{"height": 18, "width": 18}				)
  							self.assertEqual(image_processor.crop_size,						{"height": 18, "width": 18}				)
  
  							_snake_case			 = self.image_processing_class.from_dict(self.image_processor_dict,						size=42,						crop_size=84				)
  							self.assertEqual(image_processor.size,						{"height": 42, "width": 42}				)
  							self.assertEqual(image_processor.crop_size,						{"height": 84, "width": 84}				)
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							# Initialize image_processing
  							_snake_case			 = self.image_processing_class(**self.image_processor_dict				)
  							# create random PIL images
  							_snake_case			 = prepare_image_inputs(self.image_processor_tester,						equal_resolution=__UpperCamelCase				)
  
  							for image in image_inputs:
  									self.assertIsInstance(__UpperCamelCase,						Image.Image				)
  
  							# Test not batched input
  							_snake_case			 = 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
  							_snake_case			 = 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.crop_size["height"],
  							        self.image_processor_tester.crop_size["width"],
  							    ),						)
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							# Initialize image_processing
  							_snake_case			 = self.image_processing_class(**self.image_processor_dict				)
  							# create random numpy tensors
  							_snake_case			 = 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
  							_snake_case			 = 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
  							_snake_case			 = 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.crop_size["height"],
  							        self.image_processor_tester.crop_size["width"],
  							    ),						)
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							# Initialize image_processing
  							_snake_case			 = self.image_processing_class(**self.image_processor_dict				)
  							# create random PyTorch tensors
  							_snake_case			 = 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
  							_snake_case			 = 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
  							_snake_case			 = 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.crop_size["height"],
  							        self.image_processor_tester.crop_size["width"],
  							    ),						)
  
  
  
  
  
  
style_context: 
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  import json
  from typing import List, Optional, Tuple
  
  from tokenizers import normalizers
  
  from ...tokenization_utils import AddedToken
  from ...tokenization_utils_fast import PreTrainedTokenizerFast
  from ...utils import logging
  from .tokenization_mpnet import MPNetTokenizer
  
  
  _lowerCamelCase							:		int										=						logging.get_logger(__name__)
  
  _lowerCamelCase							:		Any										=						{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}
  
  _lowerCamelCase							:		Dict										=						{
      'vocab_file': {
          'microsoft/mpnet-base': 'https://huggingface.co/microsoft/mpnet-base/resolve/main/vocab.txt',
      },
      'tokenizer_file': {
          'microsoft/mpnet-base': 'https://huggingface.co/microsoft/mpnet-base/resolve/main/tokenizer.json',
      },
  }
  
  _lowerCamelCase							:		List[str]										=						{
      'microsoft/mpnet-base': 512,
  }
  
  _lowerCamelCase							:		Tuple										=						{
      'microsoft/mpnet-base': {'do_lower_case': True},
  }
  
  
  
  
  
  class   lowerCamelCase_							( UpperCAmelCase_							):
  
  
  
  
  					'''simple docstring'''
  
  
  
  
  
  
  					lowercase__					=				VOCAB_FILES_NAMES
  					lowercase__					=				PRETRAINED_VOCAB_FILES_MAP
  					lowercase__					=				PRETRAINED_INIT_CONFIGURATION
  					lowercase__					=				PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  					lowercase__					=				MPNetTokenizer
  					lowercase__					=				["""input_ids""", """attention_mask"""]
  
  
  
  
  
  
  					def __init__(					self,						__UpperCamelCase=None,						__UpperCamelCase=None,						__UpperCamelCase=True,						__UpperCamelCase="<s>",						__UpperCamelCase="</s>",						__UpperCamelCase="</s>",						__UpperCamelCase="<s>",						__UpperCamelCase="[UNK]",						__UpperCamelCase="<pad>",						__UpperCamelCase="<mask>",						__UpperCamelCase=True,						__UpperCamelCase=None,						**__UpperCamelCase,						):
  							super().__init__(
  							    __UpperCamelCase,						tokenizer_file=__UpperCamelCase,						do_lower_case=__UpperCamelCase,						bos_token=__UpperCamelCase,						eos_token=__UpperCamelCase,						sep_token=__UpperCamelCase,						cls_token=__UpperCamelCase,						unk_token=__UpperCamelCase,						pad_token=__UpperCamelCase,						mask_token=__UpperCamelCase,						tokenize_chinese_chars=__UpperCamelCase,						strip_accents=__UpperCamelCase,						**__UpperCamelCase,						)
  
  							_snake_case			 = json.loads(self.backend_tokenizer.normalizer.__getstate__()				)
  							if (
  							    pre_tok_state.get("lowercase",						__UpperCamelCase				) != do_lower_case
  							    or pre_tok_state.get("strip_accents",						__UpperCamelCase				) != strip_accents
  							):
  									_snake_case			 = getattr(__UpperCamelCase,						pre_tok_state.pop("type"				)				)
  									_snake_case			 = do_lower_case
  									_snake_case			 = strip_accents
  									_snake_case			 = pre_tok_class(**__UpperCamelCase				)
  
  							_snake_case			 = do_lower_case
  
  
  
  
  
  
  					@property
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							if self._mask_token is None:
  									if self.verbose:
  											logger.error("Using mask_token, but it is not set yet."				)
  									return None
  							return str(self._mask_token				)
  
  
  
  
  
  
  					@mask_token.setter
  					def        __SCREAMING_SNAKE_CASE			(					self,						__UpperCamelCase				):
  							_snake_case			 = AddedToken(__UpperCamelCase,						lstrip=__UpperCamelCase,						rstrip=__UpperCamelCase				) if isinstance(__UpperCamelCase,						__UpperCamelCase				) else value
  							_snake_case			 = value
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self,						__UpperCamelCase,						__UpperCamelCase=None				):
  							_snake_case			 = [self.bos_token_id] + token_ids_a + [self.eos_token_id]
  							if token_ids_a is None:
  									return output
  
  							return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self,						__UpperCamelCase,						__UpperCamelCase = None				):
  							_snake_case			 = [self.sep_token_id]
  							_snake_case			 = [self.cls_token_id]
  
  							if token_ids_a is None:
  									return len(cls + token_ids_a + sep				) * [0]
  							return len(cls + token_ids_a + sep + sep + token_ids_a + sep				) * [0]
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self,						__UpperCamelCase,						__UpperCamelCase = None				):
  							_snake_case			 = self._tokenizer.model.save(__UpperCamelCase,						name=__UpperCamelCase				)
  							return tuple(__UpperCamelCase				)
  
  
  
  
  
  