code: def check_num_slices(num_slices, img_shape=None, num_dims=3):
      
  
      if not isinstance(num_slices, Iterable) or len(num_slices) == 1:
          num_slices = np.repeat(num_slices, num_dims)
  
      if img_shape is not None:
          if len(num_slices) != len(img_shape):
              raise ValueError('The number of dimensions requested is different from image.'
                               ' Must be either 1 or equal to {}'.format(len(img_shape) + 1))
          # upper bounding them to image shape
          num_slices = np.minimum(img_shape, num_slices)
  
      # lower bounding it to 1
      return np.maximum(1, num_slices)
docs: Ensures requested number of slices is valid.
  
      Atleast 1 and atmost the image size, if available