code: def generate_data(shape, num_classes, blobs_per_class):
      """Generates blobs_per_class gaussian blobs in ND `shape`-shaped array.
      Each point is assigned a class at which the maximum blob intensity occurred - or background,
      if intensity is below certain threshold. The threshold is adjusted to maintain a preset
      percentage of background"""
  
      radii = np.array([shape])
      mean = (
          np.random.random([num_classes, blobs_per_class, len(shape)])
          * radii
      )
      sigma = (
          (
              np.random.random(
                  [num_classes, blobs_per_class, len(shape)]
              )
              * 0.8
              + 0.2
          )
          * radii
          / 2
      )
  
      mean = np.expand_dims(mean, list(range(2, len(shape) + 2)))
      isigma = 1 / np.expand_dims(sigma, list(range(2, len(shape) + 2)))
  
      pos = np.expand_dims(indices(shape), [0, 1])
  
      g = np.exp(-np.sum(((pos - mean) * isigma) ** 2, axis=-1))
      g = np.max(g, axis=1)  # sum over blobs within class
  
      maxfg = np.max(g, axis=0)
  
      min_bg = 0.5
      max_bg = 0.7
      bg_lo = 0
      bg_hi = 1
      volume = np.prod(shape)
      while bg_hi - bg_lo > 1e-2:
          threshold = (bg_lo + bg_hi) / 2
          bg_fraction = np.count_nonzero(maxfg < threshold) / volume
          if bg_fraction < min_bg:
              bg_lo = threshold
          elif bg_fraction > max_bg:
              bg_hi = threshold
          else:
              break
  
      label = np.argmax(g, axis=0) + 1
      label[maxfg < threshold] = 0
  
      return label
  
imports: from nose_utils import assert_raises
  import nvidia.dali
  import nvidia.dali.fn
  import nvidia.dali.ops
  import numpy
  import scipy.ndimage
  import scipy.ndimage.measurements
  import random
  from test_utils import check_batch, np_type_to_dali
  from nose.tools import nottest
  from nose.plugins.attrib import attr
label_desc: Use image node_id 13 for calling a global function with example usage: generate_data(shape, num_classes, blobs_per_class) and returns: label