code: def test_conversion_tensor_to_image(self):
      feature_extractor = ImageFeatureExtractionMixin()
      tensor = torch.randint(0, 256, (16, 32, 3))
      array = tensor.numpy()
  
      # By default, no rescale (for a tensor of ints)
      image1 = feature_extractor.to_pil_image(tensor)
      self.assertTrue(isinstance(image1, PIL.Image.Image))
      self.assertTrue(np.array_equal(np.array(image1), array))
  
      # If the tensor is channel-first, proper reordering of the channels is done.
      image2 = feature_extractor.to_pil_image(tensor.permute(2, 0, 1))
      self.assertTrue(isinstance(image2, PIL.Image.Image))
      self.assertTrue(np.array_equal(np.array(image2), array))
  
      # If the tensor has floating type, it's rescaled by default.
      image3 = feature_extractor.to_pil_image(tensor.float() / 255.0)
      self.assertTrue(isinstance(image3, PIL.Image.Image))
      self.assertTrue(np.array_equal(np.array(image3), array))
  
      # You can override the default to rescale.
      image4 = feature_extractor.to_pil_image(
          tensor.float(), rescale=False
      )
      self.assertTrue(isinstance(image4, PIL.Image.Image))
      self.assertTrue(np.array_equal(np.array(image4), array))
  
      # And with floats + channel first.
      image5 = feature_extractor.to_pil_image(
          tensor.permute(2, 0, 1).float() * (1 / 255.0)
      )
      self.assertTrue(isinstance(image5, PIL.Image.Image))
      self.assertTrue(np.array_equal(np.array(image5), array))
  
imports: import unittest
  import datasets
  import numpy
  import pytest
  from transformers import is_torch_available, is_vision_available
  from transformers.image_utils import ChannelDimension, get_channel_dimension_axis
  from transformers.testing_utils import require_torch, require_vision
label_desc: Use image node_id 6 for calling the ImageFeatureExtractionTester obj's underlying member method code with example usage: obj.test_conversion_tensor_to_image() without return types