code: def _assert_equal_tensor_to_pil(tensor, pil_image, msg=None):
      # FIXME: this is handled automatically by `assert_equal` below. Let's remove this in favor of it
      np_pil_image = np.array(pil_image)
      if np_pil_image.ndim == 2:
          np_pil_image = np_pil_image[:, :, None]
      pil_tensor = torch.as_tensor(np_pil_image.transpose((2, 0, 1)))
      if msg is None:
          msg = f"tensor:\n{tensor} \ndid not equal PIL tensor:\n{pil_tensor}"
      assert_equal(tensor.cpu(), pil_tensor, msg=msg)
  
imports: import contextlib
  import functools
  import itertools
  import os
  import pathlib
  import random
  import re
  import shutil
  import sys
  import tempfile
  import warnings
  from subprocess import CalledProcessError, check_output, STDOUT
  import numpy
  import PIL.Image
  import pytest
  import torch
  import torch.testing
  from PIL import Image
  from torch.testing._comparison import BooleanPair, NonePair, not_close_error_metas, NumberPair, TensorLikePair
  from torchvision import io, tv_tensors
  from torchvision.transforms._functional_tensor import _max_value
  from torchvision.transforms.v2.functional import to_image, to_pil_image
label_desc: Use image node_id 17 for calling a global function with example usage: _assert_equal_tensor_to_pil(tensor, pil_image, msg) without return types