code: def write_image_to_file(img: np.ndarray, file_path: Path):
      img = (img * 255.0).astype(np.uint8)
      img = np.transpose(img, (1, 2, 0))
      pil_img = Image.fromarray(img)
      if ".jpg" in file_path.name or ".jpeg" in file_path.name:
          pil_img.save(file_path, quality=100, subsampling=0)
      else:
          pil_img.save(file_path)
  
file_path: NeuralCompression/tests/utils.py
imports: from pathlib import Path
  from typing import Optional
  import numpy
  import torch
  from numpy.random import Generator
  from PIL import Image
label_desc: Use image node_id 4 for calling a global function with example usage: write_image_to_file(img, file_path) without return types