
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding



class    _snake_case (						UpperCAmelCase_				):
 __lowerCAmelCase	:  Any	   =      ['image_processor', 'tokenizer']
 __lowerCAmelCase	:  Union[str, Any]	   =      'AutoImageProcessor'
 __lowerCAmelCase	:  int	   =      'AutoTokenizer'


 def __init__(       self       ,	SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   super().__init__(SCREAMING_SNAKE_CASE_       ,	SCREAMING_SNAKE_CASE_)
   lowercase__	: Union[str, Any]     		=   self.image_processor


 def __call__(       self       ,	SCREAMING_SNAKE_CASE_=None       ,	SCREAMING_SNAKE_CASE_=None       ,	SCREAMING_SNAKE_CASE_=None       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   if text is None and images is None:
     raise ValueError("""You have to specify either text or images. Both cannot be none.""")

   if text is not None:
     lowercase__	: List[str]     		=   self.tokenizer(SCREAMING_SNAKE_CASE_       ,	return_tensors=SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_)

   if images is not None:
     lowercase__	: Optional[int]     		=   self.image_processor(SCREAMING_SNAKE_CASE_       ,	return_tensors=SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_)

   if text is not None and images is not None:
     lowercase__	: Union[str, Any]     		=   image_features.pixel_values
     return encoding
   elif text is not None:
     return encoding
   else:
     return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE_)       ,	tensor_type=SCREAMING_SNAKE_CASE_)


 def   lowercase__  (       self       ,	*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_)


 def   lowercase__  (       self       ,	*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_):


   '''simple docstring'''




   return self.tokenizer.decode(*SCREAMING_SNAKE_CASE_       ,	**SCREAMING_SNAKE_CASE_)



 @property
 def   lowercase__  (       self):


   '''simple docstring'''




   return ["input_ids", "attention_mask", "pixel_values"]








def 		UpperCamelCase						(   lowercase_ )		->						float:


  '''simple docstring'''






  if not nums:  # Makes sure that the list is not empty
    raise ValueError("""List is empty""" )

  lowercase__	: int     		=   sum(lowercase_ ) / len(lowercase_ )  # Calculate the average
  return sum(abs(x - average ) for x in nums ) / len(lowercase_ )


if __name__ == "__main__":
     import doctest

     doctest.testmod()






