


'''simple docstring'''

import os
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

import torch
from torch import nn

from ...models.controlnet import ControlNetModel, ControlNetOutput
from ...models.modeling_utils import ModelMixin
from ...utils import logging


lowerCAmelCase				:List[str]        =      logging.get_logger(__name__)
class _lowerCamelCase	(						lowercase__							):



		'''simple docstring'''







		def __init__( self		:						Union[str, Any]  ,					_A		:						Union[List[ControlNetModel], Tuple[ControlNetModel]]      )  ->			int:
			super().__init__()
			__magic_name__	:   Any					     =					nn.ModuleList(_A      )







		def        __lowerCAmelCase		( self		:						Optional[int]  ,					_A		:						torch.FloatTensor  ,					_A		:						Union[torch.Tensor, float, int]  ,					_A		:						torch.Tensor  ,					_A		:						List[torch.tensor]  ,					_A		:						List[float]  ,					_A		:						Optional[torch.Tensor] = None  ,					_A		:						Optional[torch.Tensor] = None  ,					_A		:						Optional[torch.Tensor] = None  ,					_A		:						Optional[Dict[str, Any]] = None  ,					_A		:						bool = False  ,					_A		:						bool = True  ,					)  ->			Union[ControlNetOutput, Tuple]:
			for i, (image, scale, controlnet) in enumerate(zip(_A  ,					_A  ,					self.nets      )      ):
				__magic_name__     ,    __magic_name__	:   Any					     =					controlnet(
				    _A  ,					_A  ,					_A  ,					_A  ,					_A  ,					_A  ,					_A  ,					_A  ,					_A  ,					_A  ,					_A  ,					)

				# merge samples
				if i == 0:
					__magic_name__     ,    __magic_name__	:   List[Any]					     =					down_samples, mid_sample
				else:
					__magic_name__	:   Optional[int]					     =					[
					    samples_prev + samples_curr
					    for samples_prev, samples_curr in zip(_A  ,					_A      )
					]
					mid_block_res_sample += mid_sample

			return down_block_res_samples, mid_block_res_sample







		def        __lowerCAmelCase		( self		:						Any  ,					_A		:						Union[str, os.PathLike]  ,					_A		:						bool = True  ,					_A		:						Callable = None  ,					_A		:						bool = False  ,					_A		:						Optional[str] = None  ,					)  ->			int:
			__magic_name__	:   int					     =					0
			__magic_name__	:   Optional[int]					     =					save_directory
			for controlnet in self.nets:
				controlnet.save_pretrained(
				    _A  ,					is_main_process=_A  ,					save_function=_A  ,					safe_serialization=_A  ,					variant=_A  ,					)

				idx += 1
				__magic_name__	:   Union[str, Any]					     =					model_path_to_save + F'_{idx}'







		@classmethod
		def        __lowerCAmelCase		( cls		:						Union[str, Any]  ,					_A		:						Optional[Union[str, os.PathLike]]  ,					**_A		:						Optional[int]      )  ->			Tuple:
			__magic_name__	:   Dict					     =					0
			__magic_name__	:   Optional[Any]					     =					[]

			# load controlnet and append to list until no controlnet directory exists anymore
			# first controlnet has to be saved under `./mydirectory/controlnet` to be compliant with `DiffusionPipeline.from_prertained`
			# second, third, ... controlnets have to be saved under `./mydirectory/controlnet_1`, `./mydirectory/controlnet_2`, ...
			__magic_name__	:   str					     =					pretrained_model_path
			while os.path.isdir(_A      ):
				__magic_name__	:   Any					     =					ControlNetModel.from_pretrained(_A  ,					**_A      )
				controlnets.append(_A      )

				idx += 1
				__magic_name__	:   int					     =					pretrained_model_path + F'_{idx}'

			logger.info(F'{len(_A      )} controlnets loaded from {pretrained_model_path}.'      )

			if len(_A      ) == 0:
				raise ValueError(
				    F'No ControlNets found under {os.path.dirname(_A      )}. Expected at least {pretrained_model_path + "_0"}.'      )

			return cls(_A      )



'''simple docstring'''

def lowerCamelCase      (      lowerCAmelCase    :     str		):





	"""simple docstring"""







	if not all(x.isalpha() for x in string		):
		raise ValueError('String must only contain alphabetic characters.'		)

	__magic_name__	:   int					     =					sorted(string.lower()		)
	return len(lowerCAmelCase		) == len(set(lowerCAmelCase		)		)


if __name__ == "__main__":
							lowerCAmelCase				:Any        =      input('''Enter a string ''').strip()

							lowerCAmelCase				:List[Any]        =      is_isogram(input_str)
							print(F'{input_str} is {"an" if isogram else "not an"} isogram.')