class_docstr: Resize sample to given size (width, height).
      
class_docstr_tok: ["Resize","sample","to","given","size","(","width",",","height",")","."]
code: def get_size(self, width, height):
      # determine new height and width
      scale_height = self.__height / height
      scale_width = self.__width / width
  
      if self.__keep_aspect_ratio:
          if self.__resize_method == "lower_bound":
              # scale such that output size is lower bound
              if scale_width > scale_height:
                  # fit width
                  scale_height = scale_width
              else:
                  # fit height
                  scale_width = scale_height
          elif self.__resize_method == "upper_bound":
              # scale such that output size is upper bound
              if scale_width < scale_height:
                  # fit width
                  scale_height = scale_width
              else:
                  # fit height
                  scale_width = scale_height
          elif self.__resize_method == "minimal":
              # scale as least as possbile
              if abs(1 - scale_width) < abs(1 - scale_height):
                  # fit width
                  scale_height = scale_width
              else:
                  # fit height
                  scale_width = scale_height
          else:
              raise ValueError(
                  f"resize_method {self.__resize_method} not implemented"
              )
  
      if self.__resize_method == "lower_bound":
          new_height = self.constrain_to_multiple_of(
              scale_height * height, min_val=self.__height
          )
          new_width = self.constrain_to_multiple_of(
              scale_width * width, min_val=self.__width
          )
      elif self.__resize_method == "upper_bound":
          new_height = self.constrain_to_multiple_of(
              scale_height * height, max_val=self.__height
          )
          new_width = self.constrain_to_multiple_of(
              scale_width * width, max_val=self.__width
          )
      elif self.__resize_method == "minimal":
          new_height = self.constrain_to_multiple_of(
              scale_height * height
          )
          new_width = self.constrain_to_multiple_of(scale_width * width)
      else:
          raise ValueError(
              f"resize_method {self.__resize_method} not implemented"
          )
  
      return (new_width, new_height)
  
file_path: stablediffusion/ldm/modules/midas/midas/transforms.py
imports: import numpy
  import cv2
  import math
label_desc: Use image node_id 3 for calling the Resize obj's underlying member method code with example usage: obj.get_size(width, height) and returns: new_width,  new_height