code: def _test_scalar_constant_promotion(device):
      @dali.pipeline_def(batch_size=1, device_id=0, num_threads=4)
      def scalar_constant_pipeline(device):
          constant = types.Constant(1)
          with_explicit_dev = types.Constant(4, device=device)
          p1 = fn.stack(constant, 2)
          if device == "gpu":
              p1 = p1.gpu()
          p2 = fn.stack(3, with_explicit_dev)
          return (fn.copy(1.25, device=device), fn.cat(p1, p2))
  
      pipe = scalar_constant_pipeline(device)
      pipe.build()
      ref = [
          np.array(1.25, dtype=np.float32),
          np.array([1, 2, 3, 4], dtype=np.int32),
      ]
      for iter in range(3):
          out = pipe.run()
          if device == "gpu":
              out = [o.as_cpu() for o in out]
  
          for o in range(len(ref)):
              for i in range(len(out[o])):
                  check(out[o].at(i), ref[o])
  
imports: import numpy
  import nvidia.dali
  import nvidia.dali.fn
  import nvidia.dali.ops
  import nvidia.dali.types
  import os
  from nvidia.dali import Pipeline
  from test_utils import check_batch
  from test_utils import get_dali_extra_path
label_desc: Use image node_id 4 for calling a global function with example usage: _test_scalar_constant_promotion(device) and returns: fn,  fn