code: def save_jpg(
      x: Tensor | DcmDataset, path, wins, bins=None, quality=90
  ):
      "Save tensor or dicom image into `jpg` format"
      fn = Path(path).with_suffix(".jpg")
      x = (x.to_nchan(wins, bins) * 255).byte()
      im = Image.fromarray(
          x.permute(1, 2, 0).numpy(),
          mode=["RGB", "CMYK"][x.shape[0] == 4],
      )
      im.save(fn, quality=quality)
  
imports: from __future__ import annotations
  from ..basics import *
  from ..vision.all import *
  from ..data.transforms import *
  import pydicom, kornia, skimage
  from pydicom.dataset import Dataset
  from pydicom.tag import BaseTag
  from pydicom.multival import MultiValue
  from PIL import Image
label_desc: Use image node_id 28 for calling a global function with example usage: save_jpg(x, path, wins, bins, quality) without return types