






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     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     str     	=  ["""image_processor""", """tokenizer"""]
	snake_case__							:     str     	=  """BlipImageProcessor"""
	snake_case__							:     int     	=  ("""BertTokenizer""", """BertTokenizerFast""")





	def __init__(		self				:					Tuple ,  __lowerCamelCase				:					Optional[Any] ,  __lowerCamelCase				:					str	):
		UpperCamelCase     :List[Any]          =	False
		super().__init__(__lowerCamelCase ,  __lowerCamelCase	)
		UpperCamelCase     :Tuple          =	self.image_processor





	def __call__(		self				:					Tuple ,  __lowerCamelCase				:					ImageInput = None ,  __lowerCamelCase				:					Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None ,  __lowerCamelCase				:					bool = True ,  __lowerCamelCase				:					Union[bool, str, PaddingStrategy] = False ,  __lowerCamelCase				:					Union[bool, str, TruncationStrategy] = None ,  __lowerCamelCase				:					Optional[int] = None ,  __lowerCamelCase				:					int = 0 ,  __lowerCamelCase				:					Optional[int] = None ,  __lowerCamelCase				:					Optional[bool] = None ,  __lowerCamelCase				:					bool = False ,  __lowerCamelCase				:					bool = False ,  __lowerCamelCase				:					bool = False ,  __lowerCamelCase				:					bool = False ,  __lowerCamelCase				:					bool = False ,  __lowerCamelCase				:					bool = True ,  __lowerCamelCase				:					Optional[Union[str, TensorType]] = None ,  **__lowerCamelCase				:					Tuple ,  ):
		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     :List[str]          =	self.tokenizer
			UpperCamelCase     :int          =	self.tokenizer(
			    text=__lowerCamelCase ,  add_special_tokens=__lowerCamelCase ,  padding=__lowerCamelCase ,  truncation=__lowerCamelCase ,  max_length=__lowerCamelCase ,  stride=__lowerCamelCase ,  pad_to_multiple_of=__lowerCamelCase ,  return_attention_mask=__lowerCamelCase ,  return_overflowing_tokens=__lowerCamelCase ,  return_special_tokens_mask=__lowerCamelCase ,  return_offsets_mapping=__lowerCamelCase ,  return_token_type_ids=__lowerCamelCase ,  return_length=__lowerCamelCase ,  verbose=__lowerCamelCase ,  return_tensors=__lowerCamelCase ,  **__lowerCamelCase ,  )
			return text_encoding

		# add pixel_values
		UpperCamelCase     :Any          =	self.image_processor(__lowerCamelCase ,  return_tensors=__lowerCamelCase	)

		if text is not None:
			UpperCamelCase     :Dict          =	self.tokenizer(
			    text=__lowerCamelCase ,  add_special_tokens=__lowerCamelCase ,  padding=__lowerCamelCase ,  truncation=__lowerCamelCase ,  max_length=__lowerCamelCase ,  stride=__lowerCamelCase ,  pad_to_multiple_of=__lowerCamelCase ,  return_attention_mask=__lowerCamelCase ,  return_overflowing_tokens=__lowerCamelCase ,  return_special_tokens_mask=__lowerCamelCase ,  return_offsets_mapping=__lowerCamelCase ,  return_token_type_ids=__lowerCamelCase ,  return_length=__lowerCamelCase ,  verbose=__lowerCamelCase ,  return_tensors=__lowerCamelCase ,  **__lowerCamelCase ,  )
		else:
			UpperCamelCase     :Optional[int]          =	None

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

		return encoding_image_processor





	def 						_A (		self				:					Dict ,  *__lowerCamelCase				:					Optional[Any] ,  **__lowerCamelCase				:					Optional[int]	):
		return self.tokenizer.batch_decode(*__lowerCamelCase ,  **__lowerCamelCase	)





	def 						_A (		self				:					int ,  *__lowerCamelCase				:					str ,  **__lowerCamelCase				:					int	):
		return self.tokenizer.decode(*__lowerCamelCase ,  **__lowerCamelCase	)





	@property
	def 						_A (		self				:					Union[str, Any]	):
		UpperCamelCase     :List[str]          =	self.tokenizer.model_input_names
		UpperCamelCase     :Any          =	self.image_processor.model_input_names
		return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)








from collections.abc import Generator
from math import sin

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  bytes					)		->			bytes:






	"""simple docstring"""



	if len(__magic_name__					) != 32:
		raise ValueError("""Input must be of length 32"""					)

	UpperCamelCase     :int          =	B""""""
	for i in [3, 2, 1, 0]:
		little_endian += string_aa[8 * i : 8 * i + 8]
	return little_endian

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  int					)		->			bytes:






	"""simple docstring"""



	if i < 0:
		raise ValueError("""Input must be non-negative"""					)

	UpperCamelCase     :Any          =	format(__magic_name__	,			"""08x"""					)[-8:]
	UpperCamelCase     :Union[str, Any]          =	B""""""
	for i in [3, 2, 1, 0]:
		little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode("""utf-8"""					)
	return little_endian_hex

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  bytes					)		->			bytes:






	"""simple docstring"""



	UpperCamelCase     :str          =	B""""""
	for char in message:
		bit_string += format(__magic_name__	,			"""08b"""					).encode("""utf-8"""					)
	UpperCamelCase     :Any          =	format(len(__magic_name__					)	,			"""064b"""					).encode("""utf-8"""					)

	# Pad bit_string to a multiple of 512 chars
	bit_string += b"1"
	while len(__magic_name__					) % 512 != 448:
		bit_string += b"0"
	bit_string += to_little_endian(start_len[32:]					) + to_little_endian(start_len[:32]					)

	return bit_string

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  bytes					)		->			Generator[list[int], None, None]:






	"""simple docstring"""



	if len(__magic_name__					) % 512 != 0:
		raise ValueError("""Input must have length that's a multiple of 512"""					)

	for pos in range(0	,			len(__magic_name__					)	,			512					):
		UpperCamelCase     :Tuple          =	bit_string[pos : pos + 512]
		UpperCamelCase     :Optional[int]          =	[]
		for i in range(0	,			512	,			32					):
			block_words.append(int(to_little_endian(block[i : i + 32]					)	,			2					)					)
		yield block_words

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  int					)		->			int:






	"""simple docstring"""



	if i < 0:
		raise ValueError("""Input must be non-negative"""					)

	UpperCamelCase     :List[str]          =	format(__magic_name__	,			"""032b"""					)
	UpperCamelCase     :Any          =	""""""
	for c in i_str:
		new_str += "1" if c == "0" else "0"
	return int(__magic_name__	,			2					)

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  int	,			__magic_name__					:  int					)		->			int:






	"""simple docstring"""



	return (a + b) % 2**32

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  int	,			__magic_name__					:  int					)		->			int:






	"""simple docstring"""



	if i < 0:
		raise ValueError("""Input must be non-negative"""					)
	if shift < 0:
		raise ValueError("""Shift must be non-negative"""					)
	return ((i << shift) ^ (i >> (32 - shift))) % 2**32

def    SCREAMING_SNAKE_CASE_							(							__magic_name__					:  bytes					)		->			bytes:






	"""simple docstring"""



	UpperCamelCase     :Tuple          =	preprocess(__magic_name__					)

	UpperCamelCase     :List[str]          =	[int(2**32 * abs(sin(i + 1					)					)					) for i in range(64					)]

	# Starting states
	UpperCamelCase     :Union[str, Any]          =	0X67_45_23_01
	UpperCamelCase     :Union[str, Any]          =	0XEF_CD_AB_89
	UpperCamelCase     :List[str]          =	0X98_BA_DC_FE
	UpperCamelCase     :int          =	0X10_32_54_76

	UpperCamelCase     :int          =	[
	    7,
	    12,
	    17,
	    22,
	    7,
	    12,
	    17,
	    22,
	    7,
	    12,
	    17,
	    22,
	    7,
	    12,
	    17,
	    22,
	    5,
	    9,
	    14,
	    20,
	    5,
	    9,
	    14,
	    20,
	    5,
	    9,
	    14,
	    20,
	    5,
	    9,
	    14,
	    20,
	    4,
	    11,
	    16,
	    23,
	    4,
	    11,
	    16,
	    23,
	    4,
	    11,
	    16,
	    23,
	    4,
	    11,
	    16,
	    23,
	    6,
	    10,
	    15,
	    21,
	    6,
	    10,
	    15,
	    21,
	    6,
	    10,
	    15,
	    21,
	    6,
	    10,
	    15,
	    21,
	]

	# Process bit string in chunks, each with 16 32-char words
	for block_words in get_block_words(__magic_name__					):
		UpperCamelCase     :Optional[Any]          =	aa
		UpperCamelCase     :Any          =	ba
		UpperCamelCase     :Tuple          =	ca
		UpperCamelCase     :List[str]          =	da

		# Hash current chunk
		for i in range(64					):
			if i <= 15:
				# f = (b & c) | (not_32(b) & d)     # Alternate definition for f
				UpperCamelCase     :int          =	d ^ (b & (c ^ d))
				UpperCamelCase     :Optional[int]          =	i
			elif i <= 31:
				# f = (d & b) | (not_32(d) & c)     # Alternate definition for f
				UpperCamelCase     :str          =	c ^ (d & (b ^ c))
				UpperCamelCase     :Union[str, Any]          =	(5 * i + 1) % 16
			elif i <= 47:
				UpperCamelCase     :str          =	b ^ c ^ d
				UpperCamelCase     :Optional[int]          =	(3 * i + 5) % 16
			else:
				UpperCamelCase     :List[str]          =	c ^ (b | not_aa(__magic_name__					))
				UpperCamelCase     :int          =	(7 * i) % 16
			UpperCamelCase     :Dict          =	(f + a + added_consts[i] + block_words[g]) % 2**32
			UpperCamelCase     :Tuple          =	d
			UpperCamelCase     :str          =	c
			UpperCamelCase     :Tuple          =	b
			UpperCamelCase     :Optional[Any]          =	sum_aa(__magic_name__	,			left_rotate_aa(__magic_name__	,			shift_amounts[i]					)					)

		# Add hashed chunk to running total
		UpperCamelCase     :List[str]          =	sum_aa(__magic_name__	,			__magic_name__					)
		UpperCamelCase     :str          =	sum_aa(__magic_name__	,			__magic_name__					)
		UpperCamelCase     :int          =	sum_aa(__magic_name__	,			__magic_name__					)
		UpperCamelCase     :Optional[Any]          =	sum_aa(__magic_name__	,			__magic_name__					)

	UpperCamelCase     :Optional[Any]          =	reformat_hex(__magic_name__					) + reformat_hex(__magic_name__					) + reformat_hex(__magic_name__					) + reformat_hex(__magic_name__					)
	return digest


if __name__ == "__main__":
	import doctest

	doctest.testmod()
