code: def downscale(
      img,
      scale,
      down_interpolation=cv2.INTER_AREA,
      up_interpolation=cv2.INTER_LINEAR,
  ):
      h, w = img.shape[:2]
  
      need_cast = (
          up_interpolation != cv2.INTER_NEAREST
          or down_interpolation != cv2.INTER_NEAREST
      ) and img.dtype == np.uint8
      if need_cast:
          img = to_float(img)
      downscaled = cv2.resize(
          img,
          None,
          fx=scale,
          fy=scale,
          interpolation=down_interpolation,
      )
      upscaled = cv2.resize(
          downscaled, (w, h), interpolation=up_interpolation
      )
      if need_cast:
          upscaled = from_float(
              np.clip(upscaled, 0, 1), dtype=np.dtype("uint8")
          )
      return upscaled
  
imports: from __future__ import division
  from typing import Optional, Sequence, Union
  from warnings import warn
  import cv2
  import numpy
  import skimage
  from albumentations import random_utils
  from albumentations.augmentations.utils import MAX_VALUES_BY_DTYPE, _maybe_process_in_chunks, clip, clipped, ensure_contiguous, is_grayscale_image, is_rgb_image, non_rgb_warning, preserve_channel_dim, preserve_shape
label_desc: Use image node_id 37 for calling a global function with example usage: downscale(img, scale, down_interpolation, up_interpolation) and returns: upscaled