code: def upscale(self, img: PIL.Image, scale, selected_model: str = None):
      self.scale = scale
      dest_w = int((img.width * scale) // 8 * 8)
      dest_h = int((img.height * scale) // 8 * 8)
  
      for _ in range(3):
          if img.width >= dest_w and img.height >= dest_h:
              break
  
          shape = (img.width, img.height)
  
          img = self.do_upscale(img, selected_model)
  
          if shape == (img.width, img.height):
              break
  
      if img.width != dest_w or img.height != dest_h:
          img = img.resize((int(dest_w), int(dest_h)), resample=LANCZOS)
  
      return img
  
imports: import os
  from abc import abstractmethod
  import PIL
  from PIL import Image
  import modules.shared
  from modules import modelloader, shared
label_desc: Use image node_id 3 for calling the Upscaler obj's underlying member method code with example usage: obj.upscale(img, scale, selected_model) and returns: img