






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_torch_available,
)


lowerCAmelCase_           = {
    'configuration_trocr': ['TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrOCRConfig'],
    'processing_trocr': ['TrOCRProcessor'],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase_           = [
					    'TROCR_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'TrOCRForCausalLM',
					    'TrOCRPreTrainedModel',
					]


if TYPE_CHECKING:
					from .configuration_trocr import TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP, TrOCRConfig
					from .processing_trocr import TrOCRProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_trocr import TROCR_PRETRAINED_MODEL_ARCHIVE_LIST, TrOCRForCausalLM, TrOCRPreTrainedModel

else:
					import sys

					lowerCAmelCase_           = _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)














from collections import deque

from .hash_table import HashTable
class      UpperCamelCase (				snake_case__ ):







		"""simple docstring"""



		def __init__(  self		:       Any						,*_SCREAMING_SNAKE_CASE		:       Optional[int]						,**_SCREAMING_SNAKE_CASE		:       Optional[Any]		)    ->   int:


						'''simple docstring'''
						super().__init__(*_SCREAMING_SNAKE_CASE						,**_SCREAMING_SNAKE_CASE		)
		def       A(  self		:       Optional[int]						,_SCREAMING_SNAKE_CASE		:       Optional[Any]						,_SCREAMING_SNAKE_CASE		:       Tuple		)    ->   List[str]:


						'''simple docstring'''
						A	 =      deque([]		) if self.values[key] is None else self.values[key]
						self.values[key].appendleft(_SCREAMING_SNAKE_CASE		)
						A	 =      self.values[key]
		def       A(  self		:       Optional[Any]		)    ->   Union[str, Any]:


						'''simple docstring'''
						return (
						    sum(self.charge_factor - len(_SCREAMING_SNAKE_CASE		) for slot in self.values		)
						    / self.size_table
						    * self.charge_factor
						)







		def       A(  self		:       Dict						,_SCREAMING_SNAKE_CASE		:       Optional[int]						,_SCREAMING_SNAKE_CASE		:       str=None		)    ->   Union[str, Any]:


						'''simple docstring'''
						if not (
						    len(self.values[key]		) == self.charge_factor and self.values.count(_SCREAMING_SNAKE_CASE		) == 0
						):
										return key
						return super()._collision_resolution(_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE		)





