






'''simple docstring'''







import warnings
from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType

class _lowercase			(       _lowercase	):
							a          = ["""image_processor""", """tokenizer"""]
							a          = """FlavaImageProcessor"""
							a          = ("""BertTokenizer""", """BertTokenizerFast""")




							def __init__(							self:       Dict    ,							UpperCamelCase__:       str=None    ,							UpperCamelCase__:       Any=None    ,							**UpperCamelCase__:       List[str]  ):
														lowerCamelCase__      :			int 						= 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__      :			Dict 						= kwargs.pop("""feature_extractor"""  )

														lowerCamelCase__      :			List[str] 						= 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__  )
														lowerCamelCase__      :			Union[str, Any] 						= self.image_processor




							def __call__(							self:       Optional[Any]    ,							UpperCamelCase__:       Optional[ImageInput] = None    ,							UpperCamelCase__:       Optional[Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]] = None    ,							UpperCamelCase__:       bool = True    ,							UpperCamelCase__:       Union[bool, str, PaddingStrategy] = False    ,							UpperCamelCase__:       Union[bool, str, TruncationStrategy] = False    ,							UpperCamelCase__:       Optional[int] = None    ,							UpperCamelCase__:       int = 0    ,							UpperCamelCase__:       Optional[int] = None    ,							UpperCamelCase__:       Optional[bool] = None    ,							UpperCamelCase__:       Optional[bool] = None    ,							UpperCamelCase__:       Optional[bool] = None    ,							UpperCamelCase__:       Optional[bool] = None    ,							UpperCamelCase__:       bool = False    ,							UpperCamelCase__:       bool = False    ,							UpperCamelCase__:       bool = False    ,							UpperCamelCase__:       bool = False    ,							UpperCamelCase__:       bool = True    ,							UpperCamelCase__:       Optional[Union[str, TensorType]] = None    ,							**UpperCamelCase__:       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:
																					lowerCamelCase__      :			str 						= self.tokenizer(
																					    text=UpperCamelCase__    ,							add_special_tokens=UpperCamelCase__    ,							padding=UpperCamelCase__    ,							truncation=UpperCamelCase__    ,							max_length=UpperCamelCase__    ,							stride=UpperCamelCase__    ,							pad_to_multiple_of=UpperCamelCase__    ,							return_token_type_ids=UpperCamelCase__    ,							return_attention_mask=UpperCamelCase__    ,							return_overflowing_tokens=UpperCamelCase__    ,							return_special_tokens_mask=UpperCamelCase__    ,							return_offsets_mapping=UpperCamelCase__    ,							return_length=UpperCamelCase__    ,							verbose=UpperCamelCase__    ,							return_tensors=UpperCamelCase__    ,							**UpperCamelCase__    ,							)
														if images is not None:
																					lowerCamelCase__      :			Union[str, Any] 						= self.image_processor(
																					    UpperCamelCase__    ,							return_image_mask=UpperCamelCase__    ,							return_codebook_pixels=UpperCamelCase__    ,							return_tensors=UpperCamelCase__    ,							**UpperCamelCase__    ,							)

														if text is not None and images is not None:
																					encoding.update(UpperCamelCase__  )
																					return encoding
														elif text is not None:
																					return encoding
														else:
																					return BatchEncoding(data=dict(**UpperCamelCase__  )    ,							tensor_type=UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       str    ,							*UpperCamelCase__:       List[Any]    ,							**UpperCamelCase__:       str  ):
														return self.tokenizer.batch_decode(*UpperCamelCase__    ,							**UpperCamelCase__  )




							def 	lowerCamelCase_       (							self:       Optional[int]    ,							*UpperCamelCase__:       Tuple    ,							**UpperCamelCase__:       Union[str, Any]  ):
														return self.tokenizer.decode(*UpperCamelCase__    ,							**UpperCamelCase__  )




							@property
							def 	lowerCamelCase_       (							self:       Optional[Any]  ):
														lowerCamelCase__      :			Tuple 						= self.tokenizer.model_input_names
														lowerCamelCase__      :			Any 						= self.image_processor.model_input_names
														return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names  )  )




							@property
							def 	lowerCamelCase_       (							self:       Optional[int]  ):
														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 	lowerCamelCase_       (							self:       List[str]  ):
														warnings.warn(
														    """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""    ,							UpperCamelCase__    ,							)
														return self.image_processor









'''simple docstring'''







_A			:    List[str]					  ='''0.21.0'''

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
			from .utils import rich

