code: def shift_pixel(x, sf, upper_left=True):
      """shift pixel for super-resolution with different scale factors
      Args:
          x: WxHxC or WxH
          sf: scale factor
          upper_left: shift direction
      """
      h, w = x.shape[:2]
      shift = (sf - 1) * 0.5
      xv, yv = np.arange(0, w, 1.0), np.arange(0, h, 1.0)
      if upper_left:
          x1 = xv + shift
          y1 = yv + shift
      else:
          x1 = xv - shift
          y1 = yv - shift
  
      x1 = np.clip(x1, 0, w - 1)
      y1 = np.clip(y1, 0, h - 1)
  
      if x.ndim == 2:
          x = interp2d(xv, yv, x)(x1, y1)
      if x.ndim == 3:
          for i in range(x.shape[-1]):
              x[:, :, i] = interp2d(xv, yv, x[:, :, i])(x1, y1)
  
      return x
  
imports: import random
  from functools import partial
  import albumentations
  import cv2
  import ldm.modules.image_degradation.utils_image
  import numpy
  import scipy
  import scipy.stats
  import torch
  from scipy import ndimage
  from scipy.interpolate import interp2d
  from scipy.linalg import orth
label_desc: Use image node_id 5 for calling a global function with example usage: shift_pixel(x, sf, upper_left) and returns: x