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_video_inputs
  
  
  if is_torch_available():
  						import torch
  
  if is_vision_available():
  						from PIL import Image
  
  						from transformers import VideoMAEImageProcessor
  
  
  
  
  
  
  class   snake_case__					(			unittest.TestCase				):
  
  
  
  
  
  
  
  		"""simple docstring"""
  
  		def __init__(			self							: Union[str, Any]     ,  UpperCamelCase__							: List[Any]     ,  UpperCamelCase__							: List[Any]=7     ,  UpperCamelCase__							: Tuple=3     ,  UpperCamelCase__							: Union[str, Any]=10     ,  UpperCamelCase__							: Tuple=18     ,  UpperCamelCase__							: Optional[int]=30     ,  UpperCamelCase__							: str=400     ,  UpperCamelCase__							: Union[str, Any]=True     ,  UpperCamelCase__							: str=None     ,  UpperCamelCase__							: Optional[int]=True     ,  UpperCamelCase__							: Dict=[0.5, 0.5, 0.5]     ,  UpperCamelCase__							: Union[str, Any]=[0.5, 0.5, 0.5]     ,  UpperCamelCase__							: Tuple=None     ,  )	-> Optional[int]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					Any     =	size if size is not None else {'''shortest_edge''': 18}
  				snake_case     :					Dict     =	crop_size if crop_size is not None else {'''height''': 18, '''width''': 18}
  
  				snake_case     :					Union[str, Any]     =	parent
  				snake_case     :					Dict     =	batch_size
  				snake_case     :					List[Any]     =	num_channels
  				snake_case     :					int     =	num_frames
  				snake_case     :					Union[str, Any]     =	image_size
  				snake_case     :					Tuple     =	min_resolution
  				snake_case     :					Dict     =	max_resolution
  				snake_case     :					List[Any]     =	do_resize
  				snake_case     :					Any     =	size
  				snake_case     :					List[str]     =	do_normalize
  				snake_case     :					Any     =	image_mean
  				snake_case     :					int     =	image_std
  				snake_case     :					List[str]     =	crop_size
  
  
  
  		def 			lowerCAmelCase							(			self							: int			)	-> List[str]:
  
  
  
  
  
  
  				"""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,
  				    "crop_size": self.crop_size,
  				}
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class   snake_case__					(			__SCREAMING_SNAKE_CASE						,				unittest.TestCase				):
  
  
  
  
  
  
  
  		"""simple docstring"""
  
  		lowerCamelCase           =	VideoMAEImageProcessor if is_vision_available() else None
  
  
  
  		def 			lowerCAmelCase							(			self							: str			)	-> Optional[Any]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					List[Any]     =	VideoMAEImageProcessingTester(self			)
  
  
  
  		@property
  		def 			lowerCAmelCase							(			self							: Union[str, Any]			)	-> List[Any]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  		def 			lowerCAmelCase							(			self							: Any			)	-> Dict:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					Union[str, Any]     =	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__     ,  '''do_center_crop'''			)			)
  				self.assertTrue(hasattr(UpperCamelCase__     ,  '''size'''			)			)
  
  
  
  		def 			lowerCAmelCase							(			self							: List[str]			)	-> List[Any]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					int     =	self.image_processing_class.from_dict(self.image_processor_dict			)
  				self.assertEqual(image_processor.size     ,  {'''shortest_edge''': 18}			)
  				self.assertEqual(image_processor.crop_size     ,  {'''height''': 18, '''width''': 18}			)
  
  				snake_case     :					Dict     =	self.image_processing_class.from_dict(self.image_processor_dict     ,  size=42     ,  crop_size=84			)
  				self.assertEqual(image_processor.size     ,  {'''shortest_edge''': 42}			)
  				self.assertEqual(image_processor.crop_size     ,  {'''height''': 84, '''width''': 84}			)
  
  
  
  		def 			lowerCAmelCase							(			self							: Tuple			)	-> List[str]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				pass
  
  
  
  		def 			lowerCAmelCase							(			self							: Optional[int]			)	-> Union[str, Any]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					Union[str, Any]     =	self.image_processing_class(**self.image_processor_dict			)
  				# create random PIL videos
  				snake_case     :					List[str]     =	prepare_video_inputs(self.image_processor_tester     ,  equal_resolution=UpperCamelCase__			)
  				for video in video_inputs:
  						self.assertIsInstance(UpperCamelCase__     ,  UpperCamelCase__			)
  						self.assertIsInstance(video[0]     ,  Image.Image			)
  
  				# Test not batched input
  				snake_case     :					Optional[int]     =	image_processing(video_inputs[0]     ,  return_tensors='''pt'''			).pixel_values
  				self.assertEqual(
  				    encoded_videos.shape     ,  (
  				        1,
  				        self.image_processor_tester.num_frames,
  				        self.image_processor_tester.num_channels,
  				        self.image_processor_tester.crop_size['''height'''],
  				        self.image_processor_tester.crop_size['''width'''],
  				    )     ,  )
  
  				# Test batched
  				snake_case     :					Union[str, Any]     =	image_processing(UpperCamelCase__     ,  return_tensors='''pt'''			).pixel_values
  				self.assertEqual(
  				    encoded_videos.shape     ,  (
  				        self.image_processor_tester.batch_size,
  				        self.image_processor_tester.num_frames,
  				        self.image_processor_tester.num_channels,
  				        self.image_processor_tester.crop_size['''height'''],
  				        self.image_processor_tester.crop_size['''width'''],
  				    )     ,  )
  
  
  
  		def 			lowerCAmelCase							(			self							: Any			)	-> List[Any]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					int     =	self.image_processing_class(**self.image_processor_dict			)
  				# create random numpy tensors
  				snake_case     :					Union[str, Any]     =	prepare_video_inputs(self.image_processor_tester     ,  equal_resolution=UpperCamelCase__     ,  numpify=UpperCamelCase__			)
  				for video in video_inputs:
  						self.assertIsInstance(UpperCamelCase__     ,  UpperCamelCase__			)
  						self.assertIsInstance(video[0]     ,  np.ndarray			)
  
  				# Test not batched input
  				snake_case     :					Tuple     =	image_processing(video_inputs[0]     ,  return_tensors='''pt'''			).pixel_values
  				self.assertEqual(
  				    encoded_videos.shape     ,  (
  				        1,
  				        self.image_processor_tester.num_frames,
  				        self.image_processor_tester.num_channels,
  				        self.image_processor_tester.crop_size['''height'''],
  				        self.image_processor_tester.crop_size['''width'''],
  				    )     ,  )
  
  				# Test batched
  				snake_case     :					Optional[int]     =	image_processing(UpperCamelCase__     ,  return_tensors='''pt'''			).pixel_values
  				self.assertEqual(
  				    encoded_videos.shape     ,  (
  				        self.image_processor_tester.batch_size,
  				        self.image_processor_tester.num_frames,
  				        self.image_processor_tester.num_channels,
  				        self.image_processor_tester.crop_size['''height'''],
  				        self.image_processor_tester.crop_size['''width'''],
  				    )     ,  )
  
  
  
  		def 			lowerCAmelCase							(			self							: Any			)	-> Tuple:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					Optional[Any]     =	self.image_processing_class(**self.image_processor_dict			)
  				# create random PyTorch tensors
  				snake_case     :					str     =	prepare_video_inputs(self.image_processor_tester     ,  equal_resolution=UpperCamelCase__     ,  torchify=UpperCamelCase__			)
  				for video in video_inputs:
  						self.assertIsInstance(UpperCamelCase__     ,  UpperCamelCase__			)
  						self.assertIsInstance(video[0]     ,  torch.Tensor			)
  
  				# Test not batched input
  				snake_case     :					Optional[int]     =	image_processing(video_inputs[0]     ,  return_tensors='''pt'''			).pixel_values
  				self.assertEqual(
  				    encoded_videos.shape     ,  (
  				        1,
  				        self.image_processor_tester.num_frames,
  				        self.image_processor_tester.num_channels,
  				        self.image_processor_tester.crop_size['''height'''],
  				        self.image_processor_tester.crop_size['''width'''],
  				    )     ,  )
  
  				# Test batched
  				snake_case     :					Dict     =	image_processing(UpperCamelCase__     ,  return_tensors='''pt'''			).pixel_values
  				self.assertEqual(
  				    encoded_videos.shape     ,  (
  				        self.image_processor_tester.batch_size,
  				        self.image_processor_tester.num_frames,
  				        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 torch
  
  from transformers import AutoTokenizer
  
  
  
  
  
  
  class   snake_case__					(			__SCREAMING_SNAKE_CASE				):
  
  
  
  
  
  
  
  		"""simple docstring"""
  
  		def __init__(			self							: Union[str, Any]     ,  UpperCamelCase__							: List[str]			)	-> List[str]:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					List[Any]     =	AutoTokenizer.from_pretrained(UpperCamelCase__			)
  
  
  
  		def 			lowerCAmelCase							(			self							: Any     ,  UpperCamelCase__							: str			)	-> Dict:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				if isinstance(UpperCamelCase__     ,  UpperCamelCase__			) and all(isinstance(_x     ,  UpperCamelCase__			) for _x in x			):
  						snake_case     :					Any     =	None
  						for l in x:
  								snake_case     :					str     =	self.tokenizer(
  								    UpperCamelCase__     ,  padding='''max_length'''     ,  max_length=384     ,  truncation=UpperCamelCase__     ,  return_tensors='''pt'''     ,  )
  								snake_case     :					Tuple     =	torch.tensor([len(UpperCamelCase__			)]			)
  								if d is not None:
  										for k in d.keys():
  												snake_case     :					int     =	torch.cat((d[k], t[k])     ,  0			)
  								else:
  										snake_case     :					List[str]     =	t
  
  						snake_case     :					Union[str, Any]     =	torch.tensor(self.tokenizer.convert_tokens_to_ids('''[E]'''			)			)
  						snake_case     :					int     =	torch.tensor(self.tokenizer.convert_tokens_to_ids('''[/E]'''			)			)
  
  				elif isinstance(UpperCamelCase__     ,  UpperCamelCase__			) and all(isinstance(_x     ,  UpperCamelCase__			) for _x in x			):
  						snake_case     :					Optional[int]     =	self.tokenizer(
  						    UpperCamelCase__     ,  padding='''max_length'''     ,  max_length=384     ,  truncation=UpperCamelCase__     ,  return_tensors='''pt'''     ,  )
  
  				else:
  						raise Exception(
  						    '''Type of parameter x was not recognized! Only `list of strings` for query or `list of lists of'''
  						    ''' strings` for supports are supported.'''			)
  
  				return d
  
  
  
  		def 			lowerCAmelCase							(			self							: int     ,  UpperCamelCase__							: List[Any]     ,  UpperCamelCase__							: List[Any]     ,  UpperCamelCase__							: Any     ,  UpperCamelCase__							: Tuple     ,  UpperCamelCase__							: Any=0.70			)	-> Dict:
  
  
  
  
  
  
  				"""simple docstring"""
  
  
  
  
  
  
  
  				snake_case     :					str     =	[]
  				for idx in range(len(W_query['''input_ids''']			)			):
  						snake_case     :					Optional[int]     =	range(p_start.shape[1]			)
  
  						snake_case     :					str     =	[]
  						for start_id in start_indexes:
  								for end_id in end_indexes:
  										if start_id < end_id:
  												output.append(
  												    (
  												        start_id,
  												        end_id,
  												        p_start[idx][start_id].item(),
  												        p_end[idx][end_id].item(),
  												    )			)
  
  						output.sort(key=lambda UpperCamelCase__			: (tup[2] * tup[3])     ,  reverse=UpperCamelCase__			)
  						snake_case     :					int     =	[]
  						for k in range(len(UpperCamelCase__			)			):
  								if output[k][2] * output[k][3] >= thresh:
  										snake_case ,snake_case     :					Tuple     =	output[k][0], output[k][1]
  										snake_case     :					str     =	self.tokenizer.decode(W_query['''input_ids'''][idx][c_start_pos:c_end_pos]			)
  										temp.append((decoded, output[k][2] * output[k][3])			)
  
  						final_outputs.append(UpperCamelCase__			)
  
  				return final_outputs
  
  
  