


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class 					__lowerCamelCase	(_a		):
       _lowercase    							=      ["""image_processor""", """tokenizer"""]
       _lowercase    							=      """AutoImageProcessor"""
       _lowercase    							=      """AutoTokenizer"""







       def __init__(	self:				int,A_:				Optional[int]=None,A_:				Optional[int]=None,**A_:				List[str]			):






            '''simple docstring'''




            __UpperCamelCase				=	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_,)
                 __UpperCamelCase				=	kwargs.pop('feature_extractor'			)

            __UpperCamelCase				=	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_			)
            __UpperCamelCase				=	self.image_processor
            __UpperCamelCase				=	False







       def __call__(	self:				Optional[int],*A_:				Dict,**A_:				Tuple			):






            '''simple docstring'''




            if self._in_target_context_manager:
                 return self.current_processor(*A_,**A_			)

            __UpperCamelCase				=	kwargs.pop('images',A_			)
            __UpperCamelCase				=	kwargs.pop('text',A_			)
            if len(A_			) > 0:
                 __UpperCamelCase				=	args[0]
                 __UpperCamelCase				=	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:
                 __UpperCamelCase				=	self.image_processor(A_,*A_,**A_			)
            if text is not None:
                 __UpperCamelCase				=	self.tokenizer(A_,**A_			)

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







       def 						snake_case_					(	self:				int,*A_:				List[str],**A_:				List[Any]			):






            '''simple docstring'''




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







       def 						snake_case_					(	self:				Any,*A_:				int,**A_:				Tuple			):






            '''simple docstring'''




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







       @contextmanager
       def 						snake_case_					(	self:				Any			):






            '''simple docstring'''




            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.'			)
            __UpperCamelCase				=	True
            __UpperCamelCase				=	self.tokenizer
            yield
            __UpperCamelCase				=	self.image_processor
            __UpperCamelCase				=	False







       @property
       def 						snake_case_					(	self:				Tuple			):






            '''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







       @property
       def 						snake_case_					(	self:				int			):






            '''simple docstring'''




            warnings.warn(
                '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.',A_,)
            return self.image_processor






# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


__snake_case     =		{
    '''configuration_convnextv2''': [
        '''CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ConvNextV2Config''',
    ]
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __snake_case     =		[
        '''CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''ConvNextV2ForImageClassification''',
        '''ConvNextV2Model''',
        '''ConvNextV2PreTrainedModel''',
        '''ConvNextV2Backbone''',
    ]


if TYPE_CHECKING:
    from .configuration_convnextva import (
        CONVNEXTV2_PRETRAINED_CONFIG_ARCHIVE_MAP,
        ConvNextVaConfig,
    )

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_convnextva import (
            CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST,
            ConvNextVaBackbone,
            ConvNextVaForImageClassification,
            ConvNextVaModel,
            ConvNextVaPreTrainedModel,
        )

else:
    import sys

    __snake_case     =		_LazyModule(__name__, globals()['''__file__'''], _import_structure)


