code: def test_cutmix(self):
      random_image = torch.rand(5, 3, 100, 100)
      state = {
          torchbearer.X: random_image,
          torchbearer.Y_TRUE: torch.randint(10, (5,)).long(),
          torchbearer.DEVICE: "cpu",
      }
      torch.manual_seed(7)
      co = CutMix(0.25, classes=10)
      co.on_sample(state)
      reg_img = state[torchbearer.X].view(-1)
  
      x = [72, 83, 18, 96, 40]
      y = [8, 17, 62, 30, 66]
      perm = [0, 4, 3, 2, 1]
      sz = 3
  
      rnd = random_image.clone().numpy()
      known_cut = random_image.clone().numpy()
      known_cut[
          0,
          :,
          y[0] - sz // 2 : y[0] + sz // 2,
          x[0] - sz // 2 : x[0] + sz // 2,
      ] = rnd[
          perm[0],
          :,
          y[0] - sz // 2 : y[0] + sz // 2,
          x[0] - sz // 2 : x[0] + sz // 2,
      ]
      known_cut[
          1,
          :,
          y[1] - sz // 2 : y[1] + sz // 2,
          x[1] - sz // 2 : x[1] + sz // 2,
      ] = rnd[
          perm[1],
          :,
          y[1] - sz // 2 : y[1] + sz // 2,
          x[1] - sz // 2 : x[1] + sz // 2,
      ]
      known_cut[
          2,
          :,
          y[2] - sz // 2 : y[2] + sz // 2,
          x[2] - sz // 2 : x[2] + sz // 2,
      ] = rnd[
          perm[2],
          :,
          y[2] - sz // 2 : y[2] + sz // 2,
          x[2] - sz // 2 : x[2] + sz // 2,
      ]
      known_cut[
          3,
          :,
          y[3] - sz // 2 : y[3] + sz // 2,
          x[3] - sz // 2 : x[3] + sz // 2,
      ] = rnd[
          perm[3],
          :,
          y[3] - sz // 2 : y[3] + sz // 2,
          x[3] - sz // 2 : x[3] + sz // 2,
      ]
      known_cut[
          4,
          :,
          y[4] - sz // 2 : y[4] + sz // 2,
          x[4] - sz // 2 : x[4] + sz // 2,
      ] = rnd[
          perm[4],
          :,
          y[4] - sz // 2 : y[4] + sz // 2,
          x[4] - sz // 2 : x[4] + sz // 2,
      ]
      known_cut = torch.from_numpy(known_cut)
      known_cut = known_cut.view(-1)
  
      diff = (torch.abs(known_cut - reg_img) > 1e-4).any()
      self.assertTrue(diff.item() == 0)
  
file_path: torchbearer/tests/callbacks/test_cutout.py
imports: from unittest import TestCase
  import torch
  import torchbearer
  from torchbearer.callbacks.cutout import Cutout, RandomErase, CutMix
label_desc: Use image node_id 4 for calling the TestCutOut obj's underlying member method code with example usage: obj.test_cutmix() without return types