




import warnings

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




class      a__			(   _lowercase ):
     a						:     Optional[Any]						   =      ['''image_processor''', '''tokenizer''']
     a						:     Optional[int]						   =      '''ChineseCLIPImageProcessor'''
     a						:     List[Any]						   =      ('''BertTokenizer''', '''BertTokenizerFast''')







     def __init__(      self    ,						A=None    ,						A=None    ,						**A					)    ->       Union[str, Any]:



          '''simple docstring'''



          a           = None
          if "feature_extractor" in kwargs:
               warnings.warn(
                   "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
                   " instead."    ,						A    ,						)
               a           = kwargs.pop("feature_extractor"					)

          a           = image_processor if image_processor is not None else feature_extractor
          if image_processor is None:
               raise ValueError("You need to specify an `image_processor`."					)
          if tokenizer is None:
               raise ValueError("You need to specify a `tokenizer`."					)

          super().__init__(A    ,						A					)
          a           = self.image_processor







     def __call__(      self    ,						A=None    ,						A=None    ,						A=None    ,						**A					)    ->       List[str]:



          '''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:
               a           = self.tokenizer(A    ,						return_tensors=A    ,						**A					)

          if images is not None:
               a           = self.image_processor(A    ,						return_tensors=A    ,						**A					)

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







     def      lowerCAmelCase_							(      self    ,						*A    ,						**A					)    ->       List[str]:



          '''simple docstring'''



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







     def      lowerCAmelCase_							(      self    ,						*A    ,						**A					)    ->       int:



          '''simple docstring'''



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







     @property
     def      lowerCAmelCase_							(      self					)    ->       List[str]:



          '''simple docstring'''



          a           = self.tokenizer.model_input_names
          a           = self.image_processor.model_input_names
          return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names					)					)







     @property
     def      lowerCAmelCase_							(      self					)    ->       Optional[int]:



          '''simple docstring'''



          warnings.warn(
              "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."    ,						A    ,						)
          return self.image_processor_class






import logging
import os

from .state import PartialState
class    __UpperCamelCase			(       logging.LoggerAdapter				):

 """simple docstring"""



 @staticmethod
 def 						_UpperCAmelCase       (	SCREAMING_SNAKE_CASE      ) ->			Optional[Any]:
  a__												= PartialState()
  return not main_process_only or (main_process_only and state.is_main_process)



 def 						_UpperCAmelCase       (	self		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      ) ->			Optional[int]:
  if PartialState._shared_state == {}:
   raise RuntimeError(
       '''You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.'''      )
  a__												= kwargs.pop('''main_process_only'''		,				SCREAMING_SNAKE_CASE      )
  a__												= kwargs.pop('''in_order'''		,				SCREAMING_SNAKE_CASE      )

  if self.isEnabledFor(SCREAMING_SNAKE_CASE      ):
   if self._should_log(SCREAMING_SNAKE_CASE      ):
    a__							,			a__												= self.process(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
    self.logger.log(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )

   elif in_order:
    a__												= PartialState()
    for i in range(state.num_processes      ):
     if i == state.process_index:
      a__							,			a__												= self.process(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
      self.logger.log(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )
     state.wait_for_everyone()






def     __a					(		__UpperCAmelCase							,  __UpperCAmelCase = None       ):
 if log_level is None:
  a__												= os.environ.get('''ACCELERATE_LOG_LEVEL'''							,  __UpperCAmelCase       )
 a__												= logging.getLogger(__UpperCAmelCase       )
 if log_level is not None:
  logger.setLevel(log_level.upper()       )
  logger.root.setLevel(log_level.upper()       )
 return MultiProcessAdapter(__UpperCAmelCase							,  {}       )





