code: def test_layout_ndim_match():
      batch_size = 2
      src_data = [
          [
              [np.ones((120, 120, 3), dtype=np.uint8)] * batch_size,
              [np.ones((120, 120), dtype=np.uint8)] * batch_size,
          ]
      ]
      src_pipe = Pipeline(batch_size, 1, 0)
      src_ext1, src_ext2 = fn.external_source(
          source=src_data,
          num_outputs=2,
          dtype=DALIDataType.UINT8,
          layout=["HWC", "HW"],
          ndim=[3, 2],
      )
      src_pipe.set_outputs(src_ext1, src_ext2)
      src_pipe.build()
      out1, out2 = src_pipe.run()
      for i in range(batch_size):
          t1 = out1.at(i)
          t2 = out2.at(i)
          assert np.array_equal(
              t1, np.ones((120, 120, 3), dtype=np.uint8)
          )
          assert np.allclose(t2, [np.ones((120, 120), dtype=np.uint8)])
  
imports: import random
  import nvidia.dali.fn
  import nvidia.dali.ops
  import nvidia.dali.types
  import numpy
  from nvidia.dali import Pipeline, pipeline_def
  from test_utils import check_batch
  from nose_utils import raises, assert_warns, assert_raises
  from nvidia.dali.types import DALIDataType
  from numpy.random import default_rng
label_desc: Use image node_id 18 for calling a global function with example usage: test_layout_ndim_match() without return types