





import warnings

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

class  __A       (  a      ):
				__A								=			["""image_processor""", """tokenizer"""]
				__A								=			"""ViTImageProcessor"""
				__A								=			("""CLIPTokenizer""", """CLIPTokenizerFast""")


				def __init__(						self				,	UpperCAmelCase_=None				,	UpperCAmelCase_=None				,	**UpperCAmelCase_							):
								lowerCamelCase			=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_				,	)
												lowerCamelCase			=kwargs.pop("""feature_extractor"""							)

								lowerCamelCase			=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_							)


				def __call__(						self				,	UpperCAmelCase_=None				,	UpperCAmelCase_=None				,	UpperCAmelCase_=None				,	UpperCAmelCase_=None				,	**UpperCAmelCase_							):
								if text is None and visual_prompt is None and images is None:
												raise ValueError("""You have to specify either text, visual prompt or images."""							)

								if text is not None and visual_prompt is not None:
												raise ValueError("""You have to specify exactly one type of prompt. Either text or visual prompt."""							)

								if text is not None:
												lowerCamelCase			=self.tokenizer(UpperCAmelCase_				,	return_tensors=UpperCAmelCase_				,	**UpperCAmelCase_							)

								if visual_prompt is not None:
												lowerCamelCase			=self.image_processor(UpperCAmelCase_				,	return_tensors=UpperCAmelCase_				,	**UpperCAmelCase_							)

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

								if visual_prompt is not None and images is not None:
												lowerCamelCase			={
												    """pixel_values""": image_features.pixel_values,
												    """conditional_pixel_values""": prompt_features.pixel_values,
												}
												return encoding
								elif text is not None and images is not None:
												lowerCamelCase			=image_features.pixel_values
												return encoding
								elif text is not None:
												return encoding
								elif visual_prompt is not None:
												lowerCamelCase			={
												    """conditional_pixel_values""": prompt_features.pixel_values,
												}
												return encoding
								else:
												return BatchEncoding(data=dict(**UpperCAmelCase_							)				,	tensor_type=UpperCAmelCase_							)


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


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


				@property
				def _snake_case    (						self							):
								warnings.warn(
								    """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""				,	UpperCAmelCase_				,	)
								return self.image_processor_class


				@property
				def _snake_case    (						self							):
								warnings.warn(
								    """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""				,	UpperCAmelCase_				,	)
								return self.image_processor












import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text





def        _lowercase   (  _UpperCAmelCase			)  ->					str:
				lowerCamelCase			=[]
				for line in lines:
								lowerCamelCase			=re.sub(r"""#.*"""     , """"""     , _UpperCAmelCase			)  # remove comments
								if line:
												filtered_lines.append(_UpperCAmelCase			)
				lowerCamelCase			="""\n""".join(_UpperCAmelCase			)

				# Make a hash from all this code
				lowerCamelCase			=full_str.encode("""utf-8"""			)
				return shaaaa(_UpperCAmelCase			).hexdigest()


# get importable module names and hash for caching
UpperCAmelCase__  :     str   			={
    '''csv''': (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    '''json''': (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    '''pandas''': (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    '''parquet''': (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    '''arrow''': (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    '''text''': (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    '''imagefolder''': (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    '''audiofolder''': (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
UpperCAmelCase__  :     Tuple   			={
    '''.csv''': ('''csv''', {}),
    '''.tsv''': ('''csv''', {'''sep''': '''\t'''}),
    '''.json''': ('''json''', {}),
    '''.jsonl''': ('''json''', {}),
    '''.parquet''': ('''parquet''', {}),
    '''.arrow''': ('''arrow''', {}),
    '''.txt''': ('''text''', {}),
}
_EXTENSION_TO_MODULE.update({ext: ('''imagefolder''', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('''imagefolder''', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ('''audiofolder''', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('''audiofolder''', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
UpperCAmelCase__  :     Optional[Any]   			={'''imagefolder''', '''audiofolder'''}

# Used to filter data files based on extensions given a module name
UpperCAmelCase__  :     Dict[str, List[str]]   			={}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
							_MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append('''.zip''')




_MODULE_TO_EXTENSIONS["audiofolder"].append('''.zip''')





