
"""simple docstring"""






from typing import List

import PIL
import torch
from PIL import Image

from ...configuration_utils import ConfigMixin
from ...models.modeling_utils import ModelMixin
from ...utils import PIL_INTERPOLATION





class 							snake_case       (     SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_		):







   def __init__( self)   ->Tuple:
      super().__init__()

      self.register_buffer("watermark_image"       ,							torch.zeros((62, 62, 4)))
      a_						   =     None







   def    UpperCAmelCase__	( self       ,							__UpperCAmelCase       ,							__UpperCAmelCase=None)   ->Optional[int]:
      # copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287

      a_						   =     images[0].height
      a_						   =     images[0].width

      a_						   =     sample_size or h

      a_						   =     min(h / sample_size       ,							w / sample_size)
      a_   ,			a_						   =     (int(h / coef), int(w / coef)) if coef < 1 else (h, w)

      a_   ,			a_						   =     10_24**2, img_w * img_h
      a_						   =     (Sa / Sa) ** 0.5
      a_   ,			a_   ,			a_						   =     int(K * 62), img_w - int(14 * K), img_h - int(14 * K)

      if self.watermark_image_as_pil is None:
         a_						   =     self.watermark_image.to(torch.uinta).cpu().numpy()
         a_						   =     Image.fromarray(__UpperCAmelCase       ,							mode="RGBA")
         a_						   =     watermark_image

      a_						   =     self.watermark_image_as_pil.resize(
          (wm_size, wm_size)       ,							PIL_INTERPOLATION["bicubic"]       ,							reducing_gap=__UpperCAmelCase)

      for pil_img in images:
         pil_img.paste(__UpperCAmelCase       ,							box=(wm_x - wm_size, wm_y - wm_size, wm_x, wm_y)       ,							mask=wm_img.split()[-1])

      return images

"""simple docstring"""






import math
def    UpperCamelCase						(					UpperCAmelCase     )						->bool:

   """simple docstring"""



   if 1 < number < 4:
      # 2 and 3 are primes
      return True
   elif number < 2 or number % 2 == 0 or number % 3 == 0:
      # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
      return False

   # All primes number are in format of 6k +/- 1
   for i in range(5 ,   int(math.sqrt(UpperCAmelCase     ) + 1     ) ,   6     ):
      if number % i == 0 or number % (i + 2) == 0:
         return False
   return True
def    UpperCamelCase						(					UpperCAmelCase = 600_851_475_143     )						->int:

   """simple docstring"""



   try:
      a_						   =     int(UpperCAmelCase     )
   except (TypeError, ValueError):
      raise TypeError("Parameter n must be int or castable to int."     )
   if n <= 0:
      raise ValueError("Parameter n must be greater than or equal to one."     )
   a_						   =     0
   if is_prime(UpperCAmelCase     ):
      return n
   while n % 2 == 0:
      n //= 2
   if is_prime(UpperCAmelCase     ):
      return n
   for i in range(3 ,   int(math.sqrt(UpperCAmelCase     )     ) + 1 ,   2     ):
      if n % i == 0:
         if is_prime(n // i     ):
            a_						   =     n // i
            break
         elif is_prime(UpperCAmelCase     ):
            a_						   =     i
   return max_number


if __name__ == "__main__":
      print(F"""{solution() = }""")