'''simple docstring'''




# Lint as: python3

import hashlib
from typing import Union

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

     return hash_data.encode('utf-8'				)


class    UpperCAmelCase__	(							_snake_case      ):






   """simple docstring"""
   def __init__(self							,					_a					)     ->  Optional[Any]:
        lowercase_       :							Optional[int]  					=       '\nFAILURE TO GENERATE DATASET: Invalid key type detected'
        lowercase_       :							int  					=       f'''\nFound Key {hash_data} of type {type(_a					)}'''
        lowercase_       :							Optional[Any]  					=       '\nKeys should be either str, int or bytes type'
        super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''					)



class    UpperCAmelCase__	(							_snake_case      ):






   """simple docstring"""
   def __init__(self							,					_a							,					_a							,					_a=""					)     ->  List[Any]:
        lowercase_       :							int  					=       key
        lowercase_       :							Tuple  					=       duplicate_key_indices
        lowercase_       :							Any  					=       fix_msg
        lowercase_       :							int  					=       'Found multiple examples generated with the same key'
        if len(_a					) <= 20:
             lowercase_       :							Optional[Any]  					=       f'''\nThe examples at index {", ".join(_a					)} have the key {key}'''
        else:
             lowercase_       :							Any  					=       f'''\nThe examples at index {", ".join(duplicate_key_indices[:20]					)}... ({len(_a					) - 20} more) have the key {key}'''
        lowercase_       :							Dict  					=       '\n' + fix_msg if fix_msg else ''
        super().__init__(f'''{self.prefix}{self.err_msg}{self.suffix}'''					)



class    UpperCAmelCase__	:






   """simple docstring"""
   def __init__(self							,					_a					)     ->  List[str]:
        lowercase_       :							List[Any]  					=       hashlib.mda(_as_bytes(_a					)					)





   def 		_lowerCamelCase			(self							,					_a					)     ->  int:
        lowercase_       :							Dict  					=       self._split_mda.copy()
        lowercase_       :							Optional[Any]  					=       _as_bytes(_a					)
        mda.update(_a					)
        # Convert to integer with hexadecimal conversion
        return int(mda.hexdigest()							,					16					)





'''simple docstring'''




from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import BaseOutput, is_torch_available, is_transformers_available


@dataclass
# Copied from diffusers.pipelines.stable_diffusion.__init__.StableDiffusionPipelineOutput with Stable->Alt
class    UpperCAmelCase__	(							_snake_case      ):






   """simple docstring"""
   A				:							Union[List[PIL.Image.Image], np.ndarray]
   A				:							Optional[List[bool]]


if is_transformers_available() and is_torch_available():
 from .modeling_roberta_series import RobertaSeriesModelWithTransformation
 from .pipeline_alt_diffusion import AltDiffusionPipeline
 from .pipeline_alt_diffusion_imgaimg import AltDiffusionImgaImgPipeline




