code: def resize_max(
      x: Image.Image, resample=0, max_px=None, max_h=None, max_w=None
  ):
      "`resize` `x` to `max_px`, or `max_h`, or `max_w`"
      h, w = x.shape
      if max_px and x.n_px > max_px:
          h, w = fastuple(h, w).mul(math.sqrt(max_px / x.n_px))
      if max_h and h > max_h:
          h, w = (max_h, max_h * w / h)
      if max_w and w > max_w:
          h, w = (max_w * h / w, max_w)
      return x.reshape(round(h), round(w), resample=resample)
  
imports: from __future__ import annotations
  from ..torch_basics import *
  from ..data.all import *
  from PIL import Image
  from matplotlib import patches, patheffects
label_desc: Use image node_id 8 for calling a global function with example usage: resize_max(x, resample, max_px, max_h, max_w) and returns: x