docstr: Adds a predefined watermark to the input image
  
  Args:
      image: ([N,] B, RGB, H, W) in range [0, 1]
  
  Returns:
      same as input but watermarked
docstr_tok: ["Adds","a","predefined","watermark","to","the","input","image","Args",":","image",":","(","[","N",",","]","B",",","RGB",",","H",",","W",")","in","range","[","0",",","1","]","Returns",":","same","as","input","but","watermarked"]
code: def __call__(self, image: torch.Tensor) -> torch.Tensor:
      """
      Adds a predefined watermark to the input image
  
      Args:
          image: ([N,] B, RGB, H, W) in range [0, 1]
  
      Returns:
          same as input but watermarked
      """
      squeeze = len(image.shape) == 4
      if squeeze:
          image = image[None, ...]
      n = image.shape[0]
      image_np = rearrange(
          (255 * image).detach().cpu(), "n b c h w -> (n b) h w c"
      ).numpy()[:, :, :, ::-1]
      # torch (b, c, h, w) in [0, 1] -> numpy (b, h, w, c) [0, 255]
      # watermarking libary expects input as cv2 BGR format
      for k in range(image_np.shape[0]):
          image_np[k] = self.encoder.encode(image_np[k], "dwtDct")
      image = torch.from_numpy(
          rearrange(
              image_np[:, :, :, ::-1], "(n b) h w c -> n b c h w", n=n
          )
      ).to(image.device)
      image = torch.clamp(image / 255, min=0.0, max=1.0)
      if squeeze:
          image = image[0]
      return image
  
imports: import math
  import os
  from typing import List, Optional, Union
  import numpy
  import torch
  from einops import rearrange
  from imwatermark import WatermarkEncoder
  from omegaconf import ListConfig
  from PIL import Image
  from torch import autocast
  from sgm.util import append_dims
label_desc: Use image node_id 2 for calling the WatermarkEmbedder obj's underlying member method code with example usage: obj.__call__(image) and returns: image