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 						lowerCamelCase			(					__lowerCamelCase				):
  	UpperCamelCase_     :				Dict								=  DPRContextEncoderTokenizer
  	UpperCamelCase_     :				int								=  DPRContextEncoderTokenizerFast
  	UpperCamelCase_     :				str								=  True
  
  
  
  
  
  @require_tokenizers
  class 						lowerCamelCase			(					__lowerCamelCase				):
  	UpperCamelCase_     :				Union[str, Any]								=  DPRQuestionEncoderTokenizer
  	UpperCamelCase_     :				Union[str, Any]								=  DPRQuestionEncoderTokenizerFast
  	UpperCamelCase_     :				Any								=  True
  
  
  
  
  
  @require_tokenizers
  class 						lowerCamelCase			(					__lowerCamelCase				):
  	UpperCamelCase_     :				List[str]								=  DPRReaderTokenizer
  	UpperCamelCase_     :				Union[str, Any]								=  DPRReaderTokenizerFast
  	UpperCamelCase_     :				Optional[Any]								=  True
  
  
  
  
  
  
  
  	@slow
  	def    snake_case__    (    self			:Optional[int] )		->			Any:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   self.tokenizer_class.from_pretrained('''bert-base-uncased''' )
  
  				SCREAMING_SNAKE_CASE    	=   tokenizer.encode('''question sequence'''      ,    add_special_tokens=lowercase )
  				SCREAMING_SNAKE_CASE    	=   tokenizer.encode('''title sequence'''      ,    add_special_tokens=lowercase )
  				SCREAMING_SNAKE_CASE    	=   tokenizer.encode('''text sequence ''' * 4      ,    add_special_tokens=lowercase )
  				SCREAMING_SNAKE_CASE    	=   [[1_0_1] + text_a + [1_0_2] + text_a + [1_0_2] + text_a]
  				SCREAMING_SNAKE_CASE    	=   BatchEncoding({'''input_ids''': input_ids} )
  
  				SCREAMING_SNAKE_CASE    	=   [[0] * len(input_ids[0] )]
  				SCREAMING_SNAKE_CASE    	=   [[0] * len(input_ids[0] )]
  				SCREAMING_SNAKE_CASE    	=   [0]
  				SCREAMING_SNAKE_CASE    	=   DPRReaderOutput(lowercase      ,    lowercase      ,    lowercase )
  
  				SCREAMING_SNAKE_CASE	,       SCREAMING_SNAKE_CASE    	=   8, 9
  				SCREAMING_SNAKE_CASE    	=   1_0
  				SCREAMING_SNAKE_CASE    	=   1_0
  				SCREAMING_SNAKE_CASE    	=   tokenizer.decode_best_spans(lowercase      ,    lowercase )
  				self.assertEqual(predicted_spans[0].start_index      ,    lowercase )
  				self.assertEqual(predicted_spans[0].end_index      ,    lowercase )
  				self.assertEqual(predicted_spans[0].doc_id      ,    0 )
  
  
  
  
  
  
  
  	@slow
  	def    snake_case__    (    self			:Tuple )		->			Optional[int]:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   self.tokenizer_class.from_pretrained('''bert-base-uncased''' )
  
  				SCREAMING_SNAKE_CASE    	=   tokenizer.encode('''question sequence'''      ,    add_special_tokens=lowercase )
  				SCREAMING_SNAKE_CASE    	=   tokenizer.encode('''title sequence'''      ,    add_special_tokens=lowercase )
  				SCREAMING_SNAKE_CASE    	=   tokenizer.encode('''text sequence'''      ,    add_special_tokens=lowercase )
  				SCREAMING_SNAKE_CASE    	=   [1_0_1] + text_a + [1_0_2] + text_a + [1_0_2] + text_a
  				SCREAMING_SNAKE_CASE    	=   tokenizer(questions=['''question sequence''']      ,    titles=['''title sequence''']      ,    texts=['''text sequence'''] )
  				self.assertIn('''input_ids'''      ,    lowercase )
  				self.assertIn('''attention_mask'''      ,    lowercase )
  				self.assertListEqual(encoded_input['''input_ids'''][0]      ,    lowercase )
style_context: 
  import numpy as np
  
  
  
  
  
  class 						lowerCamelCase			:
  
  
  
  
  
  
  
  	def __init__(    self			:Any      ,    lowercase			:List[Any]=5      ,    lowercase			:Optional[Any]=5 )		->			Tuple:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   depth
  				SCREAMING_SNAKE_CASE    	=   0
  				SCREAMING_SNAKE_CASE    	=   None
  				SCREAMING_SNAKE_CASE    	=   None
  				SCREAMING_SNAKE_CASE    	=   min_leaf_size
  				SCREAMING_SNAKE_CASE    	=   None
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:str      ,    lowercase			:int      ,    lowercase			:int )		->			str:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				if labels.ndim != 1:
  							print('''Error: Input labels must be one dimensional''' )
  
  				return np.mean((labels - prediction) ** 2 )
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Union[str, Any]      ,    lowercase			:int      ,    lowercase			:Dict )		->			Tuple:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				if x.ndim != 1:
  							print('''Error: Input data set must be one dimensional''' )
  							return
  				if len(lowercase ) != len(lowercase ):
  							print('''Error: X and y have different lengths''' )
  							return
  				if y.ndim != 1:
  							print('''Error: Data set labels must be one dimensional''' )
  							return
  
  				if len(lowercase ) < 2 * self.min_leaf_size:
  							SCREAMING_SNAKE_CASE    	=   np.mean(lowercase )
  							return
  
  				if self.depth == 1:
  							SCREAMING_SNAKE_CASE    	=   np.mean(lowercase )
  							return
  
  				SCREAMING_SNAKE_CASE    	=   0
  				SCREAMING_SNAKE_CASE    	=   self.mean_squared_error(lowercase      ,    np.mean(lowercase ) ) * 2
  				for i in range(len(lowercase ) ):
  							if len(x[:i] ) < self.min_leaf_size:
  										continue
  							elif len(x[i:] ) < self.min_leaf_size:
  										continue
  							else:
  										SCREAMING_SNAKE_CASE    	=   self.mean_squared_error(x[:i]      ,    np.mean(y[:i] ) )
  										SCREAMING_SNAKE_CASE    	=   self.mean_squared_error(x[i:]      ,    np.mean(y[i:] ) )
  										SCREAMING_SNAKE_CASE    	=   error_left + error_right
  										if error < min_error:
  													SCREAMING_SNAKE_CASE    	=   i
  													SCREAMING_SNAKE_CASE    	=   error
  
  				if best_split != 0:
  							SCREAMING_SNAKE_CASE    	=   x[:best_split]
  							SCREAMING_SNAKE_CASE    	=   y[:best_split]
  							SCREAMING_SNAKE_CASE    	=   x[best_split:]
  							SCREAMING_SNAKE_CASE    	=   y[best_split:]
  
  							SCREAMING_SNAKE_CASE    	=   x[best_split]
  							SCREAMING_SNAKE_CASE    	=   DecisionTree(
  							    depth=self.depth - 1      ,    min_leaf_size=self.min_leaf_size )
  							SCREAMING_SNAKE_CASE    	=   DecisionTree(
  							    depth=self.depth - 1      ,    min_leaf_size=self.min_leaf_size )
  							self.left.train(lowercase      ,    lowercase )
  							self.right.train(lowercase      ,    lowercase )
  				else:
  							SCREAMING_SNAKE_CASE    	=   np.mean(lowercase )
  
  				return
  
  
  
  
  
  
  
  	def    snake_case__    (    self			:Optional[int]      ,    lowercase			:List[Any] )		->			str:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				if self.prediction is not None:
  							return self.prediction
  				elif self.left or self.right is not None:
  							if x >= self.decision_boundary:
  										return self.right.predict(lowercase )
  							else:
  										return self.left.predict(lowercase )
  				else:
  							print('''Error: Decision tree not yet trained''' )
  							return None
  
  
  
  
  
  class 						lowerCamelCase			:
  
  
  
  
  
  
  
  	@staticmethod
  	def    snake_case__    (    lowercase			:Optional[int]      ,    lowercase			:Optional[Any] )		->			Dict:
  
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  				SCREAMING_SNAKE_CASE    	=   float(0 )
  				for label in labels:
  							squared_error_sum += (label - prediction) ** 2
  
  				return float(squared_error_sum / labels.size )
  
  
  
  def       a			(   )    ->Any:
  
  
  
  
  			'''simple docstring'''
  
  
  			SCREAMING_SNAKE_CASE    	=   np.arange(-1.0		,	1.0		,	0.0_05  )
  			SCREAMING_SNAKE_CASE    	=   np.sin(a  )
  
  			SCREAMING_SNAKE_CASE    	=   DecisionTree(depth=10		,	min_leaf_size=10  )
  			tree.train(a		,	a  )
  
  			SCREAMING_SNAKE_CASE    	=   (np.random.rand(10  ) * 2) - 1
  			SCREAMING_SNAKE_CASE    	=   np.array([tree.predict(a  ) for x in test_cases]  )
  			SCREAMING_SNAKE_CASE    	=   np.mean((predictions - test_cases) ** 2  )
  
  			print('''Test values: ''' + str(a  )  )
  			print('''Predictions: ''' + str(a  )  )
  			print('''Average error: ''' + str(a  )  )
  
  
  if __name__ == "__main__":
  							main()
  							import doctest
  
  							doctest.testmod(name='mean_squarred_error', verbose=True)