



'''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 __A      (  A       ,       A						):



 '''simple docstring'''







 def __init__(self	)   ->					str:


      """simple docstring"""



      super().__init__()

      self.register_buffer('''watermark_image'''			,       torch.zeros((62, 62, 4)	)	)
      _a     =  None



 def  a__  (self			,       A			,       A=None	)   ->					Optional[Any]:


      """simple docstring"""



      _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     =  1_024**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(A			,       mode='''RGBA'''	)
           _a     =  watermark_image

      _a     =  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








'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


lowercase_			=  {
    "configuration_segformer": ["SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SegformerConfig", "SegformerOnnxConfig"]
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_			=  ["SegformerFeatureExtractor"]
  lowercase_			=  ["SegformerImageProcessor"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_			=  [
      "SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "SegformerDecodeHead",
      "SegformerForImageClassification",
      "SegformerForSemanticSegmentation",
      "SegformerLayer",
      "SegformerModel",
      "SegformerPreTrainedModel",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_			=  [
      "TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFSegformerDecodeHead",
      "TFSegformerForImageClassification",
      "TFSegformerForSemanticSegmentation",
      "TFSegformerModel",
      "TFSegformerPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_segformer import SegformerFeatureExtractor
    from .image_processing_segformer import SegformerImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_segformer import (
        SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        SegformerDecodeHead,
        SegformerForImageClassification,
        SegformerForSemanticSegmentation,
        SegformerLayer,
        SegformerModel,
        SegformerPreTrainedModel,
    )
  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_segformer import (
        TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFSegformerDecodeHead,
        TFSegformerForImageClassification,
        TFSegformerForSemanticSegmentation,
        TFSegformerModel,
        TFSegformerPreTrainedModel,
    )

else:
  import sys

  lowercase_			=  _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



