code: def test_write_jpeg(img_path, tmpdir):
      tmpdir = Path(tmpdir)
      img = read_image(img_path)
      pil_img = F.to_pil_image(img)
  
      torch_jpeg = str(tmpdir / "torch.jpg")
      pil_jpeg = str(tmpdir / "pil.jpg")
  
      write_jpeg(img, torch_jpeg, quality=75)
      pil_img.save(pil_jpeg, quality=75)
  
      with open(torch_jpeg, "rb") as f:
          torch_bytes = f.read()
  
      with open(pil_jpeg, "rb") as f:
          pil_bytes = f.read()
  
      assert_equal(torch_bytes, pil_bytes)
  
imports: import glob
  import io
  import os
  import sys
  from pathlib import Path
  import numpy
  import pytest
  import torch
  import torchvision.transforms.functional
  from common_utils import assert_equal, needs_cuda
  from PIL import __version__, Image
  from torchvision.io.image import _read_png_16, decode_image, decode_jpeg, decode_png, encode_jpeg, encode_png, ImageReadMode, read_file, read_image, write_file, write_jpeg, write_png
label_desc: Use image node_id 27 for calling a global function with example usage: test_write_jpeg(img_path, tmpdir) without return types