



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





class 		UpperCAmelCase						(						__lowerCamelCase				):
   SCREAMING_SNAKE_CASE__							=     ['''image_processor''', '''tokenizer''']
   SCREAMING_SNAKE_CASE__							=     '''AutoImageProcessor'''
   SCREAMING_SNAKE_CASE__							=     '''AutoTokenizer'''





   def __init__(	self       ,     _lowerCAmelCase       ,     _lowerCAmelCase			):
         super().__init__(UpperCAmelCase_       ,     UpperCAmelCase_			)
         _lowerCAmelCase 			=  self.image_processor





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

         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:
               _lowerCAmelCase 			=  self.tokenizer(UpperCAmelCase_       ,     return_tensors=UpperCAmelCase_       ,     **UpperCAmelCase_			)

         if images is not None:
               _lowerCAmelCase 			=  self.image_processor(UpperCAmelCase_       ,     return_tensors=UpperCAmelCase_       ,     **UpperCAmelCase_			)

         if text is not None and images is not None:
               _lowerCAmelCase 			=  image_features.pixel_values
               return encoding
         elif text is not None:
               return encoding
         else:
               return BatchEncoding(data=dict(**UpperCAmelCase_			)       ,     tensor_type=UpperCAmelCase_			)





   def 	__lowerCAmelCase							(	self       ,     *_lowerCAmelCase       ,     **_lowerCAmelCase			):
         return self.tokenizer.batch_decode(*UpperCAmelCase_       ,     **UpperCAmelCase_			)





   def 	__lowerCAmelCase							(	self       ,     *_lowerCAmelCase       ,     **_lowerCAmelCase			):
         return self.tokenizer.decode(*UpperCAmelCase_       ,     **UpperCAmelCase_			)





   @property
   def 	__lowerCAmelCase							(	self			):
         return ["input_ids", "attention_mask", "pixel_values"]







from __future__ import annotations
def 							UpperCAmelCase__		(				_SCREAMING_SNAKE_CASE   :	list				)->list:
      if len(_SCREAMING_SNAKE_CASE				) == 0:
            return []
      _lowerCAmelCase			,   _lowerCAmelCase 			=  min(_SCREAMING_SNAKE_CASE				), max(_SCREAMING_SNAKE_CASE				)
      _lowerCAmelCase 			=  int(max_value - min_value				) + 1
      _lowerCAmelCase 			=  [[] for _ in range(_SCREAMING_SNAKE_CASE				)]

      for i in my_list:
            buckets[int(i - min_value				)].append(_SCREAMING_SNAKE_CASE				)

      return [v for bucket in buckets for v in sorted(_SCREAMING_SNAKE_CASE				)]


if __name__ == "__main__":
    from doctest import testmod

    testmod()
    assert bucket_sort([4, 5, 3, 2, 1]) == [1, 2, 3, 4, 5]
    assert bucket_sort([0, 1, -1_0, 1_5, 2, -2]) == [-1_0, -2, 0, 1, 2, 1_5]