

# Lint as: python3

import hashlib
from typing import Union



def  __lowerCAmelCase (  A      ):
	if isinstance(A    ,       A      ):
		# Data already in bytes, returns as it as
		return hash_data
	elif isinstance(A    ,       A      ):
		# We keep the data as it as for it ot be later encoded to UTF-8
		# However replace `\\` with `/` for Windows compatibility
		UpperCAmelCase_    			=     hash_data.replace("\\"    ,       "/"      )
	elif isinstance(A    ,       A      ):
		UpperCAmelCase_    			=     str(A      )
	else:
		# If data is not of the required type, raise error
		raise InvalidKeyError(A      )

	return hash_data.encode("utf-8"      )

class   __UpperCamelCase      (   lowercase  ):




	def __init__(						self		:  int						,		lowerCAmelCase		:  Any							):


		'''simple docstring'''







		UpperCAmelCase_    			=     "\nFAILURE TO GENERATE DATASET: Invalid key type detected"
		UpperCAmelCase_    			=     F"\nFound Key {hash_data} of type {type(lowerCAmelCase							)}"
		UpperCAmelCase_    			=     "\nKeys should be either str, int or bytes type"
		super().__init__(F"{self.prefix}{self.err_msg}{self.suffix}"							)


class   __UpperCamelCase      (   lowercase  ):




	def __init__(						self		:  List[Any]						,		lowerCAmelCase		:  Dict						,		lowerCAmelCase		:  Union[str, Any]						,		lowerCAmelCase		:  List[Any]=""							):


		'''simple docstring'''







		UpperCAmelCase_    			=     key
		UpperCAmelCase_    			=     duplicate_key_indices
		UpperCAmelCase_    			=     fix_msg
		UpperCAmelCase_    			=     "Found multiple examples generated with the same key"
		if len(lowerCAmelCase							) <= 20:
			UpperCAmelCase_    			=     F"\nThe examples at index {', '.join(lowerCAmelCase							)} have the key {key}"
		else:
			UpperCAmelCase_    			=     F"\nThe examples at index {', '.join(duplicate_key_indices[:20]							)}... ({len(lowerCAmelCase							) - 20} more) have the key {key}"
		UpperCAmelCase_    			=     "\n" + fix_msg if fix_msg else ""
		super().__init__(F"{self.prefix}{self.err_msg}{self.suffix}"							)


class   __UpperCamelCase      :




	def __init__(						self		:  Any						,		lowerCAmelCase		:  str							):


		'''simple docstring'''







		UpperCAmelCase_    			=     hashlib.mda(_as_bytes(lowerCAmelCase							)							)




	def  __A   (						self		:  List[Any]						,		lowerCAmelCase		:  Union[str, int, bytes]							):


		'''simple docstring'''







		UpperCAmelCase_    			=     self._split_mda.copy()
		UpperCAmelCase_    			=     _as_bytes(lowerCAmelCase							)
		mda.update(lowerCAmelCase							)
		# Convert to integer with hexadecimal conversion
		return int(mda.hexdigest()						,		16							)


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


_a:      Tuple								=     {
    """configuration_segformer""": ["""SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SegformerConfig""", """SegformerOnnxConfig"""]
}

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_a:      List[str]								=     ["""SegformerFeatureExtractor"""]
				_a:      Union[str, Any]								=     ["""SegformerImageProcessor"""]

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_a:      Any								=     [
				    """SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
				    """SegformerDecodeHead""",
				    """SegformerForImageClassification""",
				    """SegformerForSemanticSegmentation""",
				    """SegformerLayer""",
				    """SegformerModel""",
				    """SegformerPreTrainedModel""",
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_a:      Optional[Any]								=     [
				    """TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
				    """TFSegformerDecodeHead""",
				    """TFSegformerForImageClassification""",
				    """TFSegformerForSemanticSegmentation""",
				    """TFSegformerModel""",
				    """TFSegformerPreTrainedModel""",
				]


if TYPE_CHECKING:
				from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_segformer import SegformerFeatureExtractor
								from .image_processing_segformer import SegformerImageProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_segformer import (
								    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
								    SegformerDecodeHead,
								    SegformerForImageClassification,
								    SegformerForSemanticSegmentation,
								    SegformerLayer,
								    SegformerModel,
								    SegformerPreTrainedModel,
								)
				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_segformer import (
								    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFSegformerDecodeHead,
								    TFSegformerForImageClassification,
								    TFSegformerForSemanticSegmentation,
								    TFSegformerModel,
								    TFSegformerPreTrainedModel,
								)

else:
				import sys

				_a:      Optional[int]								=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)