





'''simple docstring'''




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 UpperCAmelCase							(		UpperCAmelCase_							):
    _A :			str						   =       ["""image_processor""", """tokenizer"""]
    _A :			List[Any]						   =       """BlipImageProcessor"""
    _A :			List[str]						   =       ("""BertTokenizer""", """BertTokenizerFast""")



    def __init__(  self     ,			__A     ,			__A					):
     __UpperCAmelCase					=   False
     super().__init__(__A     ,			__A					)
     __UpperCAmelCase					=   self.image_processor



    def __call__(  self     ,			__A = None     ,			__A = None     ,			__A = True     ,			__A = False     ,			__A = None     ,			__A = None     ,			__A = 0     ,			__A = None     ,			__A = None     ,			__A = False     ,			__A = False     ,			__A = False     ,			__A = False     ,			__A = False     ,			__A = True     ,			__A = None     ,			**__A     ,			):
     if images is None and text is None:
      raise ValueError('You have to specify either images or text.'					)

     # Get only text
     if images is None:
      __UpperCAmelCase					=   self.tokenizer
      __UpperCAmelCase					=   self.tokenizer(
          text=__A     ,			add_special_tokens=__A     ,			padding=__A     ,			truncation=__A     ,			max_length=__A     ,			stride=__A     ,			pad_to_multiple_of=__A     ,			return_attention_mask=__A     ,			return_overflowing_tokens=__A     ,			return_special_tokens_mask=__A     ,			return_offsets_mapping=__A     ,			return_token_type_ids=__A     ,			return_length=__A     ,			verbose=__A     ,			return_tensors=__A     ,			**__A     ,			)
      return text_encoding

     # add pixel_values
     __UpperCAmelCase					=   self.image_processor(__A     ,			return_tensors=__A					)

     if text is not None:
      __UpperCAmelCase					=   self.tokenizer(
          text=__A     ,			add_special_tokens=__A     ,			padding=__A     ,			truncation=__A     ,			max_length=__A     ,			stride=__A     ,			pad_to_multiple_of=__A     ,			return_attention_mask=__A     ,			return_overflowing_tokens=__A     ,			return_special_tokens_mask=__A     ,			return_offsets_mapping=__A     ,			return_token_type_ids=__A     ,			return_length=__A     ,			verbose=__A     ,			return_tensors=__A     ,			**__A     ,			)
     else:
      __UpperCAmelCase					=   None

     if text_encoding is not None:
      encoding_image_processor.update(__A					)

     return encoding_image_processor



    def 					__lowerCamelCase						(  self     ,			*__A     ,			**__A					):
     return self.tokenizer.batch_decode(*__A     ,			**__A					)



    def 					__lowerCamelCase						(  self     ,			*__A     ,			**__A					):
     return self.tokenizer.decode(*__A     ,			**__A					)




    @property
    def 					__lowerCamelCase						(  self					):
     __UpperCAmelCase					=   self.tokenizer.model_input_names
     __UpperCAmelCase					=   self.image_processor.model_input_names
     return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names					)					)












'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


_A:					Union[str, Any]							=				logging.get_logger(__name__)

_A:					List[str]							=				{
    """weiweishi/roc-bert-base-zh""": """https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json""",
}






class UpperCAmelCase							(		UpperCAmelCase_							):
    _A :			int						   =       """roc_bert"""



    def __init__(  self     ,			__A=30_522     ,			__A=768     ,			__A=12     ,			__A=12     ,			__A=3_072     ,			__A="gelu"     ,			__A=0.1     ,			__A=0.1     ,			__A=512     ,			__A=2     ,			__A=0.0_2     ,			__A=1E-12     ,			__A=True     ,			__A=0     ,			__A="absolute"     ,			__A=None     ,			__A=True     ,			__A=True     ,			__A=768     ,			__A=910     ,			__A=512     ,			__A=24_858     ,			__A=True     ,			**__A     ,			):
     __UpperCAmelCase					=   vocab_size
     __UpperCAmelCase					=   max_position_embeddings
     __UpperCAmelCase					=   hidden_size
     __UpperCAmelCase					=   num_hidden_layers
     __UpperCAmelCase					=   num_attention_heads
     __UpperCAmelCase					=   intermediate_size
     __UpperCAmelCase					=   hidden_act
     __UpperCAmelCase					=   hidden_dropout_prob
     __UpperCAmelCase					=   attention_probs_dropout_prob
     __UpperCAmelCase					=   initializer_range
     __UpperCAmelCase					=   type_vocab_size
     __UpperCAmelCase					=   layer_norm_eps
     __UpperCAmelCase					=   use_cache
     __UpperCAmelCase					=   enable_pronunciation
     __UpperCAmelCase					=   enable_shape
     __UpperCAmelCase					=   pronunciation_embed_dim
     __UpperCAmelCase					=   pronunciation_vocab_size
     __UpperCAmelCase					=   shape_embed_dim
     __UpperCAmelCase					=   shape_vocab_size
     __UpperCAmelCase					=   concat_input
     __UpperCAmelCase					=   position_embedding_type
     __UpperCAmelCase					=   classifier_dropout
     super().__init__(pad_token_id=__A     ,			**__A					)





