


from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# Load iris file
__UpperCamelCase							:							Union[str, Any]    							=					load_iris()
iris.keys()


print(f"Target names: \n {iris.target_names} ")
print(f"\n Features: \n {iris.feature_names}")

# Train set e Test set
__UpperCamelCase							,    __UpperCamelCase							,    __UpperCamelCase							,    __UpperCamelCase							:							Optional[int]    							=					train_test_split(
    iris["data"], iris["target"], random_state=4
)

# KNN

__UpperCamelCase							:							str    							=					KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)

# new array to test
__UpperCamelCase							:							int    							=					[[1, 2, 1, 4], [2, 3, 4, 5]]

__UpperCamelCase							:							Tuple    							=					knn.predict(X_new)

print(
    f"\nNew array: \n {X_new}\n\nTarget Names Prediction: \n"
    f" {iris['target_names'][prediction]}"
)






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

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


__UpperCamelCase							:							Any    							=					logging.get_logger(__name__)  # pylint: disable=invalid-name

class    __magic_name__						(  __lowerCAmelCase):
     A:		Dict								=   ["safety_checker", "feature_extractor"]


     def __init__(   self				:  List[str]				,						lowerCamelCase__				:  AutoencoderKL				,						lowerCamelCase__				:  CLIPTextModel				,						lowerCamelCase__				:  CLIPTokenizer				,						lowerCamelCase__				:  UNetaDConditionModel				,						lowerCamelCase__				:  Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]				,						lowerCamelCase__				:  StableDiffusionSafetyChecker				,						lowerCamelCase__				:  CLIPImageProcessor				,						lowerCamelCase__				:  bool = True				,						)	->   Optional[Any]:





      '''simple docstring'''






      super().__init__()
      if hasattr(scheduler.config				,						'''steps_offset'''      ) and scheduler.config.steps_offset != 1:
       UpperCamelCase__       :     int 							= (
           F"The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`"
           F" should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure "
           '''to update the config accordingly as leaving `steps_offset` might led to incorrect results'''
           ''' in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,'''
           ''' it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`'''
           ''' file'''
       )
       deprecate('''steps_offset!=1'''				,						'''1.0.0'''				,						lowerCamelCase__				,						standard_warn=lowerCamelCase__      )
       UpperCamelCase__       :     int 							= dict(scheduler.config      )
       UpperCamelCase__       :     List[str] 							= 1
       UpperCamelCase__       :     List[str] 							= FrozenDict(lowerCamelCase__      )

      self.register_modules(
          vae=lowerCamelCase__				,						text_encoder=lowerCamelCase__				,						tokenizer=lowerCamelCase__				,						unet=lowerCamelCase__				,						scheduler=lowerCamelCase__				,						safety_checker=lowerCamelCase__				,						feature_extractor=lowerCamelCase__				,						)
      self.register_to_config(requires_safety_checker=lowerCamelCase__      )


     @property
     def   UpperCAmelCase__						(   self				:  str      )	->   Dict[str, Any]:





      '''simple docstring'''






      return {k: getattr(self				,						lowerCamelCase__      ) for k in self.config.keys() if not k.startswith('''_'''      )}


     def   UpperCAmelCase__						(   self				:  str				,						lowerCamelCase__				:  Optional[Union[str, int]] = "auto"      )	->   str:





      '''simple docstring'''






      if slice_size == "auto":
       # half the attention head size is usually a good trade-off between
       # speed and memory
       UpperCamelCase__       :     Dict 							= self.unet.config.attention_head_dim // 2
      self.unet.set_attention_slice(lowerCamelCase__      )


     def   UpperCAmelCase__						(   self				:  int      )	->   Tuple:





      '''simple docstring'''






      self.enable_attention_slicing(lowerCamelCase__      )


     @torch.no_grad()
     def   UpperCAmelCase__						(   self				:  Optional[Any]				,						lowerCamelCase__				:  Union[str, List[str]]				,						lowerCamelCase__				:  Union[torch.FloatTensor, PIL.Image.Image]				,						lowerCamelCase__				:  Union[torch.FloatTensor, PIL.Image.Image]				,						lowerCamelCase__				:  float = 0.8				,						lowerCamelCase__				:  Optional[int] = 50				,						lowerCamelCase__				:  Optional[float] = 7.5				,						lowerCamelCase__				:  Optional[Union[str, List[str]]] = None				,						lowerCamelCase__				:  Optional[int] = 1				,						lowerCamelCase__				:  Optional[float] = 0.0				,						lowerCamelCase__				:  Optional[torch.Generator] = None				,						lowerCamelCase__				:  Optional[str] = "pil"				,						lowerCamelCase__				:  bool = True				,						lowerCamelCase__				:  Optional[Callable[[int, int, torch.FloatTensor], None]] = None				,						lowerCamelCase__				:  int = 1				,						)	->   Optional[Any]:





      '''simple docstring'''






      return StableDiffusionInpaintPipelineLegacy(**self.components      )(
          prompt=lowerCamelCase__				,						image=lowerCamelCase__				,						mask_image=lowerCamelCase__				,						strength=lowerCamelCase__				,						num_inference_steps=lowerCamelCase__				,						guidance_scale=lowerCamelCase__				,						negative_prompt=lowerCamelCase__				,						num_images_per_prompt=lowerCamelCase__				,						eta=lowerCamelCase__				,						generator=lowerCamelCase__				,						output_type=lowerCamelCase__				,						return_dict=lowerCamelCase__				,						callback=lowerCamelCase__				,						)


     @torch.no_grad()
     def   UpperCAmelCase__						(   self				:  Any				,						lowerCamelCase__				:  Union[str, List[str]]				,						lowerCamelCase__				:  Union[torch.FloatTensor, PIL.Image.Image]				,						lowerCamelCase__				:  float = 0.8				,						lowerCamelCase__				:  Optional[int] = 50				,						lowerCamelCase__				:  Optional[float] = 7.5				,						lowerCamelCase__				:  Optional[Union[str, List[str]]] = None				,						lowerCamelCase__				:  Optional[int] = 1				,						lowerCamelCase__				:  Optional[float] = 0.0				,						lowerCamelCase__				:  Optional[torch.Generator] = None				,						lowerCamelCase__				:  Optional[str] = "pil"				,						lowerCamelCase__				:  bool = True				,						lowerCamelCase__				:  Optional[Callable[[int, int, torch.FloatTensor], None]] = None				,						lowerCamelCase__				:  int = 1				,						**lowerCamelCase__				:  str				,						)	->   str:





      '''simple docstring'''






      return StableDiffusionImgaImgPipeline(**self.components      )(
          prompt=lowerCamelCase__				,						image=lowerCamelCase__				,						strength=lowerCamelCase__				,						num_inference_steps=lowerCamelCase__				,						guidance_scale=lowerCamelCase__				,						negative_prompt=lowerCamelCase__				,						num_images_per_prompt=lowerCamelCase__				,						eta=lowerCamelCase__				,						generator=lowerCamelCase__				,						output_type=lowerCamelCase__				,						return_dict=lowerCamelCase__				,						callback=lowerCamelCase__				,						callback_steps=lowerCamelCase__				,						)


     @torch.no_grad()
     def   UpperCAmelCase__						(   self				:  Optional[int]				,						lowerCamelCase__				:  Union[str, List[str]]				,						lowerCamelCase__				:  int = 512				,						lowerCamelCase__				:  int = 512				,						lowerCamelCase__				:  int = 50				,						lowerCamelCase__				:  float = 7.5				,						lowerCamelCase__				:  Optional[Union[str, List[str]]] = None				,						lowerCamelCase__				:  Optional[int] = 1				,						lowerCamelCase__				:  float = 0.0				,						lowerCamelCase__				:  Optional[torch.Generator] = None				,						lowerCamelCase__				:  Optional[torch.FloatTensor] = None				,						lowerCamelCase__				:  Optional[str] = "pil"				,						lowerCamelCase__				:  bool = True				,						lowerCamelCase__				:  Optional[Callable[[int, int, torch.FloatTensor], None]] = None				,						lowerCamelCase__				:  int = 1				,						)	->   Optional[Any]:





      '''simple docstring'''






      return StableDiffusionPipeline(**self.components      )(
          prompt=lowerCamelCase__				,						height=lowerCamelCase__				,						width=lowerCamelCase__				,						num_inference_steps=lowerCamelCase__				,						guidance_scale=lowerCamelCase__				,						negative_prompt=lowerCamelCase__				,						num_images_per_prompt=lowerCamelCase__				,						eta=lowerCamelCase__				,						generator=lowerCamelCase__				,						latents=lowerCamelCase__				,						output_type=lowerCamelCase__				,						return_dict=lowerCamelCase__				,						callback=lowerCamelCase__				,						callback_steps=lowerCamelCase__				,						)


