code: 
  
  
  
  """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 							_UpperCAmelCase							(				a	,a   ):
  
  
  
  
  
       '''simple docstring'''
  
  
  
       def __init__(      self	)							->      str:
           super().__init__()
  
           self.register_buffer('''watermark_image''' ,			torch.zeros((6_2, 6_2, 4)	)	)
           _UpperCAmelCase							:						Tuple       							=					None
  
  
  
  
  
       def 				__lowerCAmelCase			(      self ,			A ,			A=None	)							->      Optional[Any]:
           # copied from https://github.com/deep-floyd/IF/blob/b77482e36ca2031cb94dbca1001fc1e6400bf4ab/deepfloyd_if/modules/base.py#L287
  
           _UpperCAmelCase							:						Optional[Any]       							=					images[0].height
           _UpperCAmelCase							:						Optional[int]       							=					images[0].width
  
           _UpperCAmelCase							:						Optional[Any]       							=					sample_size or h
  
           _UpperCAmelCase							:						Union[str, Any]       							=					min(h / sample_size ,			w / sample_size	)
           _UpperCAmelCase							,       _UpperCAmelCase							:						Optional[Any]       							=					(int(h / coef	), int(w / coef	)) if coef < 1 else (h, w)
  
           _UpperCAmelCase							,       _UpperCAmelCase							:						str       							=					1_0_2_4**2, img_w * img_h
           _UpperCAmelCase							:						Any       							=					(Sa / Sa) ** 0.5
           _UpperCAmelCase							,       _UpperCAmelCase							,       _UpperCAmelCase							:						int       							=					int(K * 6_2	), img_w - int(1_4 * K	), img_h - int(1_4 * K	)
  
           if self.watermark_image_as_pil is None:
               _UpperCAmelCase							:						str       							=					self.watermark_image.to(torch.uinta	).cpu().numpy()
               _UpperCAmelCase							:						Tuple       							=					Image.fromarray(A ,			mode='''RGBA'''	)
               _UpperCAmelCase							:						Dict       							=					watermark_image
  
           _UpperCAmelCase							:						Union[str, Any]       							=					self.watermark_image_as_pil.resize(
               (wm_size, wm_size) ,			PIL_INTERPOLATION['''bicubic'''] ,			reducing_gap=A	)
  
           for pil_img in images:
               pil_img.paste(A ,			box=(wm_x - wm_size, wm_y - wm_size, wm_x, wm_y) ,			mask=wm_img.split()[-1]	)
  
           return images
  
  
  
style_context: 
  
  
  
  """simple docstring"""
  import os
  
  from apache_beam.io.filesystems import FileSystems
  from apache_beam.pipeline import Pipeline
  
  from .logging import get_logger
  
  
  _lowerCAmelCase					:Optional[int]  =      2 << 20  # 2mb
  _lowerCAmelCase					:Union[str, Any]  =      get_logger(__name__)
  class 							_UpperCAmelCase							(				a   ):
  
  
  
  
  
       '''simple docstring'''
  
  
  
       def 				__lowerCAmelCase			(      self	)							->      Any:
           _UpperCAmelCase							:						str       							=					self._options.get_all_options().get('''runner'''	)
           return runner in [None, "DirectRunner", "PortableRunner"]
  
  
  
  
  
  def 				lowerCamelCase_		(UpperCamelCase__	:	List[str]  , UpperCamelCase__	:	str  , UpperCamelCase__	:	Dict=False							):
      _UpperCAmelCase							:						Union[str, Any]       							=					FileSystems
      if fs.exists(UpperCamelCase__							):
          if force_upload:
              logger.info(F'Remote path already exist: {remote_file_path}. Overwriting it as force_upload=True.'							)
          else:
              logger.info(F'Remote path already exist: {remote_file_path}. Skipping it as force_upload=False.'							)
              return
      with fs.create(UpperCamelCase__							) as remote_file:
          with open(UpperCamelCase__  , '''rb'''							) as local_file:
              _UpperCAmelCase							:						Optional[Any]       							=					local_file.read(UpperCamelCase__							)
              while chunk:
                  remote_file.write(UpperCamelCase__							)
                  _UpperCAmelCase							:						List[Any]       							=					local_file.read(UpperCamelCase__							)
  
  
  
  
  
  def 				lowerCamelCase_		(UpperCamelCase__	:	int  , UpperCamelCase__	:	Dict  , UpperCamelCase__	:	str=False							):
      _UpperCAmelCase							:						int       							=					FileSystems
      if os.path.exists(UpperCamelCase__							):
          if force_download:
              logger.info(F'Local path already exist: {remote_file_path}. Overwriting it as force_upload=True.'							)
          else:
              logger.info(F'Local path already exist: {remote_file_path}. Skipping it as force_upload=False.'							)
              return
      with fs.open(UpperCamelCase__							) as remote_file:
          with open(UpperCamelCase__  , '''wb'''							) as local_file:
              _UpperCAmelCase							:						List[str]       							=					remote_file.read(UpperCamelCase__							)
              while chunk:
                  local_file.write(UpperCamelCase__							)
                  _UpperCAmelCase							:						List[Any]       							=					remote_file.read(UpperCamelCase__							)
  
  
  