code: def test_random_object_bbox_with_class():
      np.random.seed(12345)
      types = [
          np.int8,
          np.uint8,
          np.int16,
          np.uint16,
          np.int32,
          np.uint32,
      ]
  
      formats = [None, "anchor_shape", "start_end", "box"]
      fmt = 0
      for bg in [None, 0, -1, 5, random_background()]:
          if bg is None or isinstance(bg, int):
              class_opt = [None, [0], [1], [2, 4, 5, 7]]
              for x in class_opt:
                  if isinstance(x, list) and bg in x:
                      x.remove(bg)
              if [] in class_opt:
                  class_opt.remove([])
              # putting this in the list interfered with remove
              class_opt.append(random_classes(0 if bg is None else bg))
          else:
              class_opt = [None]
          for classes in class_opt:
              if classes is None:
                  weights_opt = [
                      None,
                      [1],
                      [0.5, 1, 0.1, 0.2],
                      random_weights(),
                  ]
              elif isinstance(classes, list):
                  weights_opt = [None, list(range(1, 1 + len(classes)))]
              else:
                  weights_opt = [None]
  
              for weights in weights_opt:
                  ndim = np.random.randint(1, 5)
  
                  threshold_opt = [
                      None,
                      3,
                      list(range(1, 1 + ndim)),
                      random_threshold(ndim),
                  ]
                  threshold = random.choice(threshold_opt)
                  k_largest_opt = [None, 1, 2, 5]
                  k_largest = random.choice(k_largest_opt)
  
                  fg_prob_opt = [
                      None,
                      0.1,
                      0.7,
                      fn.random.uniform(range=(0, 1), seed=1515),
                  ]
                  fg_prob = random.choice(fg_prob_opt)
  
                  format = formats[fmt]
                  fmt = (fmt + 1) % len(formats)
                  dtype = random.choice(types)
                  cache = np.random.randint(2) == 1
                  yield (
                      _test_random_object_bbox_with_class,
                      4,
                      ndim,
                      dtype,
                      format,
                      fg_prob,
                      classes,
                      weights,
                      bg,
                      threshold,
                      k_largest,
                      cache,
                  )
  
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 24 for calling a global function with example usage: test_random_object_bbox_with_class() without return types