


"""simple docstring"""

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




class  _UpperCAmelCase (    lowerCAmelCase__):
 _lowerCAmelCase     :    Optional[int]	      =	["image_processor", "tokenizer"]
 _lowerCAmelCase     :    str	      =	"AutoImageProcessor"
 _lowerCAmelCase     :    Optional[Any]	      =	"AutoTokenizer"

 def __init__(  self	: Union[str, Any]						,  lowercase_	: Dict						,  lowercase_	: Dict       ):
     super().__init__(UpperCamelCase_						,  UpperCamelCase_       )
     snake_case_				:  int       =			self.image_processor

 def __call__(  self	: Tuple						,  lowercase_	: str=None						,  lowercase_	: Optional[Any]=None						,  lowercase_	: List[Any]=None						,  **lowercase_	: 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:
         snake_case_				:  str       =			self.tokenizer(UpperCamelCase_						,  return_tensors=UpperCamelCase_						,  **UpperCamelCase_       )

     if images is not None:
         snake_case_				:  int       =			self.image_processor(UpperCamelCase_						,  return_tensors=UpperCamelCase_						,  **UpperCamelCase_       )

     if text is not None and images is not None:
         snake_case_				:  Optional[int]       =			image_features.pixel_values
         return encoding
     elif text is not None:
         return encoding
     else:
         return BatchEncoding(data=dict(**UpperCamelCase_       )						,  tensor_type=UpperCamelCase_       )

 def 		_snake_case      (  self	: Union[str, Any]						,  *lowercase_	: Union[str, Any]						,  **lowercase_	: Any       ):
     return self.tokenizer.batch_decode(*UpperCamelCase_						,  **UpperCamelCase_       )

 def 		_snake_case      (  self	: List[str]						,  *lowercase_	: Optional[int]						,  **lowercase_	: Optional[Any]       ):
     return self.tokenizer.decode(*UpperCamelCase_						,  **UpperCamelCase_       )






 @property
 def 		_snake_case      (  self	: Optional[int]       ):
     return ["input_ids", "attention_mask", "pixel_values"]










"""simple docstring"""

from typing import TYPE_CHECKING

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


lowercase__					:						List[Any]												=			{'''configuration_xglm''': ['''XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XGLMConfig''']}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__					:						List[Any]												=			['''XGLMTokenizer''']

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__					:						List[str]												=			['''XGLMTokenizerFast''']

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__					:						Tuple												=			[
         '''XGLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''XGLMForCausalLM''',
         '''XGLMModel''',
         '''XGLMPreTrainedModel''',
     ]


try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__					:						int												=			[
         '''FlaxXGLMForCausalLM''',
         '''FlaxXGLMModel''',
         '''FlaxXGLMPreTrainedModel''',
     ]


try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowercase__					:						Tuple												=			[
         '''TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''TFXGLMForCausalLM''',
         '''TFXGLMModel''',
         '''TFXGLMPreTrainedModel''',
     ]


if TYPE_CHECKING:
     from .configuration_xglm import XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XGLMConfig

     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_xglm import XGLMTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_xglm_fast import XGLMTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_xglm import XGLM_PRETRAINED_MODEL_ARCHIVE_LIST, XGLMForCausalLM, XGLMModel, XGLMPreTrainedModel

     try:
          if not is_flax_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_flax_xglm import FlaxXGLMForCausalLM, FlaxXGLMModel, FlaxXGLMPreTrainedModel

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_xglm import (
              TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFXGLMForCausalLM,
              TFXGLMModel,
              TFXGLMPreTrainedModel,
          )


else:
     import sys

     lowercase__					:						List[Any]												=			_LazyModule(__name__, globals()['''__file__'''], _import_structure)





