code: 
  
  
  from transformers import (
      DPRContextEncoderTokenizer,
      DPRContextEncoderTokenizerFast,
      DPRQuestionEncoderTokenizer,
      DPRQuestionEncoderTokenizerFast,
      DPRReaderOutput,
      DPRReaderTokenizer,
      DPRReaderTokenizerFast,
  )
  from transformers.testing_utils import require_tokenizers, slow
  from transformers.tokenization_utils_base import BatchEncoding
  
  from ..bert.test_tokenization_bert import BertTokenizationTest
  
  
  
  
  @require_tokenizers
  class 					_UpperCamelCase (      lowerCamelCase__	):
  
  
  
  
  
  
  
  							'''simple docstring'''
  							_A  				=  DPRContextEncoderTokenizer
  							_A  				=  DPRContextEncoderTokenizerFast
  							_A  				=  True
  
  
  
  
  @require_tokenizers
  class 					_UpperCamelCase (      lowerCamelCase__	):
  
  
  
  
  
  
  
  							'''simple docstring'''
  							_A  				=  DPRQuestionEncoderTokenizer
  							_A  				=  DPRQuestionEncoderTokenizerFast
  							_A  				=  True
  
  
  
  
  @require_tokenizers
  class 					_UpperCamelCase (      lowerCamelCase__	):
  
  
  
  
  
  
  
  							'''simple docstring'''
  							_A  				=  DPRReaderTokenizer
  							_A  				=  DPRReaderTokenizerFast
  							_A  				=  True
  
  
  
  
  
  
  
  							@slow
  							def 		_UpperCAmelCase	(		self  :				Optional[int]		):
  													_a     =			self.tokenizer_class.from_pretrained('bert-base-uncased'		)
  
  													_a     =			tokenizer.encode('question sequence'		,				add_special_tokens=SCREAMING_SNAKE_CASE_		)
  													_a     =			tokenizer.encode('title sequence'		,				add_special_tokens=SCREAMING_SNAKE_CASE_		)
  													_a     =			tokenizer.encode('text sequence ' * 4		,				add_special_tokens=SCREAMING_SNAKE_CASE_		)
  													_a     =			[[1_0_1] + text_a + [1_0_2] + text_a + [1_0_2] + text_a]
  													_a     =			BatchEncoding({'input_ids': input_ids}		)
  
  													_a     =			[[0] * len(input_ids[0]		)]
  													_a     =			[[0] * len(input_ids[0]		)]
  													_a     =			[0]
  													_a     =			DPRReaderOutput(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		)
  
  													_a ,	_a     =			8, 9
  													_a     =			1_0
  													_a     =			1_0
  													_a     =			tokenizer.decode_best_spans(SCREAMING_SNAKE_CASE_		,				SCREAMING_SNAKE_CASE_		)
  													self.assertEqual(predicted_spans[0].start_index		,				SCREAMING_SNAKE_CASE_		)
  													self.assertEqual(predicted_spans[0].end_index		,				SCREAMING_SNAKE_CASE_		)
  													self.assertEqual(predicted_spans[0].doc_id		,				0		)
  
  
  
  
  
  
  
  							@slow
  							def 		_UpperCAmelCase	(		self  :				Union[str, Any]		):
  													_a     =			self.tokenizer_class.from_pretrained('bert-base-uncased'		)
  
  													_a     =			tokenizer.encode('question sequence'		,				add_special_tokens=SCREAMING_SNAKE_CASE_		)
  													_a     =			tokenizer.encode('title sequence'		,				add_special_tokens=SCREAMING_SNAKE_CASE_		)
  													_a     =			tokenizer.encode('text sequence'		,				add_special_tokens=SCREAMING_SNAKE_CASE_		)
  													_a     =			[1_0_1] + text_a + [1_0_2] + text_a + [1_0_2] + text_a
  													_a     =			tokenizer(questions=['question sequence']		,				titles=['title sequence']		,				texts=['text sequence']		)
  													self.assertIn('input_ids'		,				SCREAMING_SNAKE_CASE_		)
  													self.assertIn('attention_mask'		,				SCREAMING_SNAKE_CASE_		)
  													self.assertListEqual(encoded_input['input_ids'][0]		,				SCREAMING_SNAKE_CASE_		)
  
  
  
style_context: 
  
  
  import numpy as np
  import PIL
  import torch
  import torchvision.transforms as T
  import torchvision.transforms.functional as TF
  from PIL import Image
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase							,     _UpperCAmelCase=256				)    ->  Dict:
  						_a     =			min(img.size				)
  
  						if s < target_image_size:
  												raise ValueError(f"""min dim for image {s} < {target_image_size}"""				)
  
  						_a     =			target_image_size / s
  						_a     =			(round(r * img.size[1]				), round(r * img.size[0]				))
  						_a     =			TF.resize(_UpperCAmelCase							,     _UpperCAmelCase							,     interpolation=PIL.Image.LANCZOS				)
  						_a     =			TF.center_crop(_UpperCAmelCase							,     output_size=2 * [target_image_size]				)
  						_a     =			torch.unsqueeze(T.ToTensor()(_UpperCAmelCase				)							,     0				)
  						return img
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase				)    ->  List[Any]:
  						_a     =			2.0 * x - 1.0
  						return x
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase							,     _UpperCAmelCase=True							,     _UpperCAmelCase="RGB"				)    ->  Optional[Any]:
  						_a     =			x.detach().cpu()
  						if process:
  												_a     =			post_process_tensor(_UpperCAmelCase				)
  						_a     =			x.numpy()
  						if process:
  												_a     =			(255 * x).astype(np.uinta				)
  						_a     =			Image.fromarray(_UpperCAmelCase				)
  						if not x.mode == mode:
  												_a     =			x.convert(_UpperCAmelCase				)
  						return x
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase				)    ->  Optional[Any]:
  						_a     =			torch.clamp(_UpperCAmelCase							,     -1.0							,     1.0				)
  						_a     =			(x + 1.0) / 2.0
  						_a     =			x.permute(1							,     2							,     0				)
  						return x
  
  
  
  
  
  
  def 							SCREAMING_SNAKE_CASE					(  _UpperCAmelCase				)    ->  str:
  						_a     =			post_process_tensor(x.squeeze()				)
  						return x.permute(2							,     0							,     1				).unsqueeze(0				)
  
  
  