



import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin





class    __lowerCAmelCase					(	lowerCamelCase__			):
				__lowerCamelCase					=							['''image_processor''', '''tokenizer''']
				__lowerCamelCase					=							'''AutoImageProcessor'''
				__lowerCamelCase					=							'''AutoTokenizer'''




				def __init__(				self		,							_snake_case=None		,							_snake_case=None		,							**_snake_case						):



									"""simple docstring"""





									_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."""		,							_snake_case		,							)
														_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__(_snake_case		,							_snake_case						)
									_lowerCAmelCase         =       self.image_processor
									_lowerCAmelCase         =       False




				def __call__(				self		,							*_snake_case		,							**_snake_case						):



									"""simple docstring"""





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

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

									if text is None:
														return inputs
									elif images is None:
														return encodings
									else:
														_lowerCAmelCase         =       encodings["""input_ids"""]
														return inputs




				def 				snake_case  (				self		,							*_snake_case		,							**_snake_case						):



									"""simple docstring"""





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




				def 				snake_case  (				self		,							*_snake_case		,							**_snake_case						):



									"""simple docstring"""





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




				@contextmanager
				def 				snake_case  (				self						):



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




				@property
				def 				snake_case  (				self						):



									"""simple docstring"""





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




				@property
				def 				snake_case  (				self						):



									"""simple docstring"""





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




"""simple docstring"""


from typing import TYPE_CHECKING

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


__UpperCamelCase       :    Any         =		{
    "configuration_openai": ["OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "OpenAIGPTConfig"],
    "tokenization_openai": ["OpenAIGPTTokenizer"],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCamelCase       :    Optional[int]         =		["OpenAIGPTTokenizerFast"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCamelCase       :    List[Any]         =		[
      "OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "OpenAIGPTDoubleHeadsModel",
      "OpenAIGPTForSequenceClassification",
      "OpenAIGPTLMHeadModel",
      "OpenAIGPTModel",
      "OpenAIGPTPreTrainedModel",
      "load_tf_weights_in_openai_gpt",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCamelCase       :    Tuple         =		[
      "TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFOpenAIGPTDoubleHeadsModel",
      "TFOpenAIGPTForSequenceClassification",
      "TFOpenAIGPTLMHeadModel",
      "TFOpenAIGPTMainLayer",
      "TFOpenAIGPTModel",
      "TFOpenAIGPTPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_openai import OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OpenAIGPTConfig
  from .tokenization_openai import OpenAIGPTTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_openai_fast import OpenAIGPTTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_openai import (
        OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
        OpenAIGPTDoubleHeadsModel,
        OpenAIGPTForSequenceClassification,
        OpenAIGPTLMHeadModel,
        OpenAIGPTModel,
        OpenAIGPTPreTrainedModel,
        load_tf_weights_in_openai_gpt,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_openai import (
        TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFOpenAIGPTDoubleHeadsModel,
        TFOpenAIGPTForSequenceClassification,
        TFOpenAIGPTLMHeadModel,
        TFOpenAIGPTMainLayer,
        TFOpenAIGPTModel,
        TFOpenAIGPTPreTrainedModel,
    )

else:
  import sys

  __UpperCamelCase       :    str         =		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)