


"""simple docstring"""






import logging
import os
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

from tqdm import auto as tqdm_lib


__snake_case		=       {
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

__snake_case		=       logging.WARNING
def       A_   (   ):






     """simple docstring"""

     _a    	=				os.getenv('''DATASETS_VERBOSITY''',     _lowerCAmelCase       )
     if env_level_str:
          if env_level_str in log_levels:
               return log_levels[env_level_str]
          else:
               logging.getLogger().warning(
                   f'Unknown option DATASETS_VERBOSITY={env_level_str}, '
                   f'has to be one of: { ", ".join(log_levels.keys()       ) }'       )
     return _default_log_level
def       A_   (   ):






     """simple docstring"""

     return __name__.split('''.'''       )[0]
def       A_   (   ):






     """simple docstring"""

     return logging.getLogger(_get_library_name()       )
def       A_   (   ):






     """simple docstring"""

     _a    	=				_get_library_root_logger()
     library_root_logger.setLevel(_get_default_logging_level()       )
def       A_   (   ):






     """simple docstring"""

     _a    	=				_get_library_root_logger()
     library_root_logger.setLevel(logging.NOTSET       )
def       A_   (   _lowerCAmelCase     :					Optional[str] = None       ):






     """simple docstring"""

     if name is None:
          _a    	=				_get_library_name()
     return logging.getLogger(_lowerCAmelCase       )
def       A_   (   ):






     """simple docstring"""

     return _get_library_root_logger().getEffectiveLevel()
def       A_   (   _lowerCAmelCase     :					int       ):






     """simple docstring"""

     _get_library_root_logger().setLevel(_lowerCAmelCase       )
def       A_   (   ):






     """simple docstring"""

     return set_verbosity(_lowerCAmelCase       )
def       A_   (   ):






     """simple docstring"""

     return set_verbosity(_lowerCAmelCase       )
def       A_   (   ):






     """simple docstring"""

     return set_verbosity(_lowerCAmelCase       )
def       A_   (   ):






     """simple docstring"""

     return set_verbosity(_lowerCAmelCase       )
def       A_   (   ):






     """simple docstring"""

     _a    	=				False
def       A_   (   ):






     """simple docstring"""

     _a    	=				True


# Configure the library root logger at the module level (singleton-like)
_configure_library_root_logger()


class     __lowerCamelCase  :

     '''simple docstring'''


     def __init__(      self    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							Any:  # pylint: disable=unused-argument
          _a    	=				args[0] if args else None


     def __iter__(      self							)       ->							List[Any]:
          return iter(self._iterator							)


     def __getattr__(      self    ,				__UpperCAmelCase							)       ->							Tuple:

          def empty_fn(*__UpperCAmelCase    ,				**__UpperCAmelCase							):  # pylint: disable=unused-argument
               return

          return empty_fn


     def __enter__(      self							)       ->							List[Any]:
          return self





     def __exit__(      self    ,				__UpperCAmelCase    ,				__UpperCAmelCase    ,				__UpperCAmelCase							)       ->							Optional[int]:
          return







__snake_case		=       True


class     __lowerCamelCase  :

     '''simple docstring'''


     def __call__(      self    ,				*__UpperCAmelCase    ,				__UpperCAmelCase=False    ,				**__UpperCAmelCase							)       ->							Optional[Any]:
          if _tqdm_active and not disable:
               return tqdm_lib.tqdm(*__UpperCAmelCase    ,				**__UpperCAmelCase							)
          else:
               return EmptyTqdm(*__UpperCAmelCase    ,				**__UpperCAmelCase							)


     def 							_UpperCAmelCase      (      self    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							str:
          _a    	=				None
          if _tqdm_active:
               return tqdm_lib.tqdm.set_lock(*__UpperCAmelCase    ,				**__UpperCAmelCase							)





     def 							_UpperCAmelCase      (      self							)       ->							Optional[int]:
          if _tqdm_active:
               return tqdm_lib.tqdm.get_lock()







__snake_case		=       _tqdm_cls()
def       A_   (   ):






     """simple docstring"""

     global _tqdm_active
     return bool(_tqdm_active       )
def       A_   (   ):






     """simple docstring"""

     global _tqdm_active
     _a    	=				True

def       A_   (   ):






     """simple docstring"""

     global _tqdm_active
     _a    	=				False



"""simple docstring"""






import warnings

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


class     __lowerCamelCase  (					a__				):

     '''simple docstring'''
     A_       :	Optional[int]    =		['image_processor', 'tokenizer']
     A_       :	Union[str, Any]    =		'ChineseCLIPImageProcessor'
     A_       :	Union[str, Any]    =		('BertTokenizer', 'BertTokenizerFast')


     def __init__(      self    ,				__UpperCAmelCase=None    ,				__UpperCAmelCase=None    ,				**__UpperCAmelCase							)       ->							List[str]:
          _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.'''    ,				__UpperCAmelCase    ,				)
               _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__(__UpperCAmelCase    ,				__UpperCAmelCase							)
          _a    	=				self.image_processor


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

          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(__UpperCAmelCase    ,				return_tensors=__UpperCAmelCase    ,				**__UpperCAmelCase							)

          if images is not None:
               _a    	=				self.image_processor(__UpperCAmelCase    ,				return_tensors=__UpperCAmelCase    ,				**__UpperCAmelCase							)

          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(**__UpperCAmelCase							)    ,				tensor_type=__UpperCAmelCase							)


     def 							_UpperCAmelCase      (      self    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							List[str]:
          return self.tokenizer.batch_decode(*__UpperCAmelCase    ,				**__UpperCAmelCase							)


     def 							_UpperCAmelCase      (      self    ,				*__UpperCAmelCase    ,				**__UpperCAmelCase							)       ->							Optional[int]:
          return self.tokenizer.decode(*__UpperCAmelCase    ,				**__UpperCAmelCase							)


     @property
     def 							_UpperCAmelCase      (      self							)       ->							List[str]:
          _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 							_UpperCAmelCase      (      self							)       ->							Tuple:
          warnings.warn(
              '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''    ,				__UpperCAmelCase    ,				)
          return self.image_processor_class