class_docstr: Take a random 2D slice from a 3D image along
  a given axis. This image should not have a 4th channel dim.
  
  :param axis: (int `in {0, 1, 2}`):
      the axis on which to take slices
  
  :param reject_zeros: (bool):
      whether to reject slices that are all zeros
code: def __call__(self, x, y=None):
      while True:
          keep_slice = random.randint(0, x.size(self.axis) - 1)
          if self.axis == 0:
              slice_x = x[keep_slice, :, :]
              if y is not None:
                  slice_y = y[keep_slice, :, :]
          elif self.axis == 1:
              slice_x = x[:, keep_slice, :]
              if y is not None:
                  slice_y = y[:, keep_slice, :]
          elif self.axis == 2:
              slice_x = x[:, :, keep_slice]
              if y is not None:
                  slice_y = y[:, :, keep_slice]
  
          if not self.reject_zeros:
              break
          if y is not None and th.sum(slice_y) > 0:
              break
          if th.sum(slice_x) > 0:
              break
      if y is not None:
          return slice_x, slice_y
      return slice_x
  
imports: import os
  import random
  import math
  import numpy
  import torch
label_desc: Use image node_id 2 for calling the Slice2D obj's underlying member method code with example usage: obj.__call__(x, y) and returns: slice_x, slice_x,  slice_y