code: def check_scalar(device):
      batch_size = 5
  
      def get_data():
          out = [
              np.random.ranf(size=[1000]).astype(dtype=np.single)
              for _ in range(batch_size)
          ]
          return out
  
      @pipeline_def(batch_size=batch_size, num_threads=1, device_id=0)
      def test_pipe():
          data = fn.external_source(source=get_data)
          shape = types.ScalarConstant(10)
          anchor = types.ScalarConstant(5)
          if device != "cpu":
              data = data.gpu()
          sliced = fn.slice(
              data, start=anchor, shape=shape, axes=[0], device=device
          )
          return data, sliced, shape, anchor
  
      pipe = test_pipe()
      pipe.build()
      ref, data, shape, anchor = pipe.run()
      for sample_idx in range(batch_size):
          d = as_array(data[sample_idx])
          r = as_array(ref[sample_idx])
          s = as_array(shape[sample_idx])
          a = as_array(anchor[sample_idx])
          np.testing.assert_allclose(d, r[a : a + s])
  
imports: from nvidia.dali import Pipeline, pipeline_def, ops, fn, types
  import numpy
  import os
  from functools import partial
  from math import floor
  from test_utils import compare_pipelines, get_dali_extra_path, RandomDataIterator, generator_random_axes_for_3d_input, generator_random_data, as_array
  from nose_utils import assert_raises
  from nose2.tools import params
label_desc: Use image node_id 30 for calling a global function with example usage: check_scalar(device) and returns: out, data,  sliced,  shape,  anchor