code: def check_pad_dynamic_axes(
      device, batch_size, num_threads, use_negative, use_empty
  ):
      shape_arg_desc = (100, 120, np.int32)
      get_dynamic_axes = generator_random_axes_for_3d_input(
          batch_size,
          use_negative=use_negative,
          use_empty=use_empty,
          extra_out_desc=[shape_arg_desc],
      )
  
      image_gen = generator_random_data(
          batch_size,
          min_sh=(10, 10, 3),
          max_sh=(100, 100, 3),
          dtype=np.float32,
          val_range=[0.0, 1.0],
      )
  
      @pipeline_def(
          batch_size=batch_size, num_threads=num_threads, device_id=0
      )
      def make_pipe():
          image = fn.external_source(source=image_gen)
          if device == "gpu":
              image = image.gpu()
          axes, shape = fn.external_source(
              source=get_dynamic_axes, num_outputs=2
          )
          fill_value = fn.random.uniform(
              device="cpu", range=[0.0, 255.0]
          )
          pad1 = fn.pad(image, axes=axes, fill_value=fill_value)
          pad2 = fn.pad(
              image, axes=axes, shape=shape, fill_value=fill_value
          )
          return image, axes, shape, pad1, pad2, fill_value
  
      pipe = make_pipe()
      pipe.build()
      ndim = 3
      for _ in range(3):
          outs = pipe.run()
          max_shape = ndim * [-1]
          for sample_idx in range(batch_size):
              in_img_sh = as_array(outs[0][sample_idx]).shape
              for dim in range(ndim):
                  if in_img_sh[dim] > max_shape[dim]:
                      max_shape[dim] = in_img_sh[dim]
  
          for sample_idx in range(batch_size):
              in_img = as_array(outs[0][sample_idx])
              axes = as_array(outs[1][sample_idx])
              naxes = axes.shape[0]
              if naxes == 0:  # Empty axes mean "all axes"
                  axes = np.array(range(ndim), dtype=np.int32)
              shape = as_array(outs[2][sample_idx])
              pad1 = as_array(outs[3][sample_idx])
              pad2 = as_array(outs[4][sample_idx])
              fill_value = as_array(outs[5][sample_idx])
              in_sh = in_img.shape
              expected_pad1_sh = np.copy(pad1.shape)
              for d in axes:
                  expected_pad1_sh[d] = max_shape[d]
              np.testing.assert_allclose(expected_pad1_sh, pad1.shape)
              np.testing.assert_allclose(
                  pad1[: in_sh[0], : in_sh[1], : in_sh[2]], in_img
              )
              np.testing.assert_allclose(
                  pad1[in_sh[0] :, : in_sh[1] :, : in_sh[2] :],
                  fill_value,
              )
              expected_pad2_sh = np.copy(pad2.shape)
              for d, req_extent in zip(axes, shape):
                  expected_pad2_sh[d] = (
                      req_extent if req_extent > 0 else max_shape[d]
                  )
              np.testing.assert_allclose(expected_pad2_sh, pad2.shape)
              np.testing.assert_allclose(
                  pad2[: in_sh[0], : in_sh[1], : in_sh[2]], in_img
              )
              np.testing.assert_allclose(
                  pad2[in_sh[0] :, : in_sh[1] :, : in_sh[2] :],
                  fill_value,
              )
  
imports: import numpy
  import nvidia.dali
  import nvidia.dali.fn
  import nvidia.dali.math
  import nvidia.dali.ops
  import nvidia.dali.types
  from nvidia.dali import Pipeline, pipeline_def
  from nvidia.dali.backend_impl import TensorListGPU
  from nose_utils import assert_raises
  from test_utils import RandomlyShapedDataIterator, generator_random_axes_for_3d_input, generator_random_data, as_array
label_desc: Use image node_id 9 for calling a global function with example usage: check_pad_dynamic_axes(device, batch_size, num_threads, use_negative, use_empty) and returns: image,  axes,  shape,  pad1,  pad2,  fill_value