code: def _test_empty_input(dim, device):
      batch_size = 8
      pipe = Pipeline(
          batch_size=batch_size, num_threads=8, device_id=0, seed=1234
      )
      if dim == 2:
          files, labels = dali.fn.readers.caffe(
              path=db_2d_folder, random_shuffle=True
          )
          images_cpu = dali.fn.decoders.image(files, device="cpu")
      else:
          images_cpu = dali.fn.external_source(
              source=random_3d_loader(batch_size), layout="DHWC"
          )
  
      images = images_cpu if device == "cpu" else images_cpu.gpu()
  
      in_rel_shapes = np.ones([batch_size, dim], dtype=np.float32)
  
      in_rel_shapes[::2, :] *= 0  # all zeros in every second sample
  
      degenerate_images = fn.slice(
          images,
          np.zeros([dim]),
          fn.external_source(lambda: in_rel_shapes),
          axes=list(range(dim)),
      )
  
      sizes = np.random.randint(
          20, 50, [batch_size, dim], dtype=np.int32
      )
      size_inp = fn.external_source(
          lambda: [x.astype(np.float32) for x in sizes]
      )
  
      resize_no_empty = fn.resize(
          images, size=size_inp, mode="not_larger"
      )
      resize_with_empty = fn.resize(
          degenerate_images, size=size_inp, mode="not_larger"
      )
  
      pipe.set_outputs(resize_no_empty, resize_with_empty)
      pipe.build()
  
      for it in range(3):
          out_no_empty, out_with_empty = pipe.run()
          if device == "gpu":
              out_no_empty = out_no_empty.as_cpu()
              out_with_empty = out_with_empty.as_cpu()
          for i in range(batch_size):
              if i % 2 != 0:
                  assert np.array_equal(
                      out_no_empty.at(i), out_with_empty.at(i)
                  )
              else:
                  assert np.prod(out_with_empty.at(i).shape) == 0
  
imports: import cv2
  import functools
  import math
  import numpy
  import nvidia.dali
  import nvidia.dali.fn
  import nvidia.dali.types
  import os.path
  from nvidia.dali import Pipeline, pipeline_def
  from nvidia.dali.data_node import DataNode
  from test_utils import check_batch, get_dali_extra_path, as_array
  import PIL.Image
label_desc: Use image node_id 19 for calling a global function with example usage: _test_empty_input(dim, device) without return types