





'''simple docstring'''







from ..utils import deprecate
from .attention_processor import (  # noqa: F401
    Attention,
    AttentionProcessor,
    AttnAddedKVProcessor,
    AttnProcessor2_0,
    LoRAAttnProcessor,
    LoRALinearLayer,
    LoRAXFormersAttnProcessor,
    SlicedAttnAddedKVProcessor,
    SlicedAttnProcessor,
    XFormersAttnProcessor,
)
from .attention_processor import AttnProcessor as AttnProcessorRename  # noqa: F401


deprecate(
    """cross_attention""",
    """0.20.0""",
    """Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.""",
    standard_warn=False,
)


_a					: List[str]      =    AttentionProcessor





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				f'{self.__class__.__name__} is deprecated and will be removed in `0.20.0`. Please use `from diffusers.models.attention_processor import {"".join(self.__class__.__name__.split("Cross"			)			)} instead.'
					deprecate("""cross_attention""","""0.20.0""",__SCREAMING_SNAKE_CASE,standard_warn=__SCREAMING_SNAKE_CASE			)
					super().__init__(*__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE			)








'''simple docstring'''







# Lint as: python3

import hashlib
from typing import Union





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

			return hash_data.encode("""utf-8"""	)





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

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





class     _UpperCAmelCase							(						lowerCAmelCase_   ):
		def __init__(  self,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE=""			):



					'''simple docstring'''

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





class     _UpperCAmelCase							:
		def __init__(  self,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

					__lowerCAmelCase											=				hashlib.mda(_as_bytes(__SCREAMING_SNAKE_CASE			)			)







		def   lowerCamelCase__			(  self,__SCREAMING_SNAKE_CASE			):



					'''simple docstring'''

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

