
'''simple docstring'''


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin

class 		__lowercase			(					_lowercase      ):
			lowerCamelCase     :						List[Any]		 =     ["image_processor", "tokenizer"]
			lowerCamelCase     :						Tuple		 =     "AutoImageProcessor"
			lowerCamelCase     :						Any		 =     "AutoTokenizer"

			def __init__(self     ,				A=None     ,				A=None     ,				**A ):
								lowerCamelCase_   : List[Any]       =						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     ,				)
													lowerCamelCase_   : Dict       =						kwargs.pop('''feature_extractor''' )

								lowerCamelCase_   : Optional[Any]       =						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 )
								lowerCamelCase_   : List[str]       =						self.image_processor
								lowerCamelCase_   : Dict       =						False

			def __call__(self     ,				*A     ,				**A ):
								# For backward compatibility
								if self._in_target_context_manager:
													return self.current_processor(*A     ,				**A )

								lowerCamelCase_   : Union[str, Any]       =						kwargs.pop('''images'''     ,				A )
								lowerCamelCase_   : Tuple       =						kwargs.pop('''text'''     ,				A )
								if len(A ) > 0:
													lowerCamelCase_   : Optional[int]       =						args[0]
													lowerCamelCase_   : int       =						args[1:]

								if images is None and text is None:
													raise ValueError('''You need to specify either an `images` or `text` input to process.''' )

								if images is not None:
													lowerCamelCase_   : Any       =						self.image_processor(A     ,				*A     ,				**A )
								if text is not None:
													lowerCamelCase_   : List[str]       =						self.tokenizer(A     ,				**A )

								if text is None:
													return inputs
								elif images is None:
													return encodings
								else:
													lowerCamelCase_   : Dict       =						encodings['''input_ids''']
													return inputs

			def     UpperCAmelCase__	(self     ,				*A     ,				**A ):
								return self.tokenizer.batch_decode(*A     ,				**A )

			def     UpperCAmelCase__	(self     ,				*A     ,				**A ):
								return self.tokenizer.decode(*A     ,				**A )

			@contextmanager
			def     UpperCAmelCase__	(self ):
								warnings.warn(
								    '''`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '''
								    '''labels by using the argument `text` of the regular `__call__` method (either in the same call as '''
								    '''your images inputs, or in a separate call.''' )
								lowerCamelCase_   : List[str]       =						True
								lowerCamelCase_   : List[Any]       =						self.tokenizer
								yield
								lowerCamelCase_   : int       =						self.image_processor
								lowerCamelCase_   : Tuple       =						False

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






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




'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__lowercase							:				List[str]					=       {
    '''configuration_sam''': [
        '''SAM_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''SamConfig''',
        '''SamMaskDecoderConfig''',
        '''SamPromptEncoderConfig''',
        '''SamVisionConfig''',
    ],
    '''processing_sam''': ['''SamProcessor'''],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowercase							:				List[Any]					=       [
					    '''SAM_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''SamModel''',
					    '''SamPreTrainedModel''',
					]
try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowercase							:				int					=       [
					    '''TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''TFSamModel''',
					    '''TFSamPreTrainedModel''',
					]
try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__lowercase							:				str					=       ['''SamImageProcessor''']


if TYPE_CHECKING:
					from .configuration_sam import (
					    SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    SamConfig,
					    SamMaskDecoderConfig,
					    SamPromptEncoderConfig,
					    SamVisionConfig,
					)
					from .processing_sam import SamProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .image_processing_sam import SamImageProcessor

else:
					import sys

					__lowercase							:				List[str]					=       _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


