code: def test_to_file(self, pil):
      handler = imaging.imaging._to_file("test")
      mock = MagicMock()
      handler(mock, 0, {torchbearer.METRICS: {}})
      mock.mul.assert_called_once_with(255)
      mock.mul().clamp.assert_called_once_with(0, 255)
      self.assertTrue(mock.mul().clamp().byte.call_count == 1)
      mock.mul().clamp().byte().permute.assert_called_once_with(1, 2, 0)
      self.assertTrue(
          mock.mul().clamp().byte().permute().cpu.call_count == 1
      )
      self.assertTrue(
          mock.mul().clamp().byte().permute().cpu().numpy.call_count
          == 1
      )
  
      pil.assert_called_once_with(
          mock.mul().clamp().byte().permute().cpu().numpy()
      )
      pil().save.assert_called_once_with("test")
  
imports: from unittest import TestCase
  from mock import MagicMock, patch, ANY
  import torch
  import torchbearer
  import torchbearer.callbacks.imaging
  import matplotlib.pyplot
label_desc: Use image node_id 1 for calling the TestHandlers obj's underlying member method code with example usage: obj.test_to_file(pil) without return types