code: def test_error_input(expression):
      kwargs = {
          "enable_conditionals": True,
          "batch_size": 10,
          "num_threads": 4,
          "device_id": 0,
      }
  
      @pipeline_def(**kwargs)
      def gpu_input():
          input = fn.random.coin_flip(dtype=types.DALIDataType.BOOL)
          return expression(input.gpu())
  
      # We can make a valid graph with `not` op directly, the rest (`and`, `or`) is basically lowered
      # to `if` statements and thus checked by graph via argument input placement validation.
      with assert_raises(
          RuntimeError,
          regex=(
              "Logical expression `.*` is restricted to scalar \\(0-d tensors\\)"
              " inputs of `bool` type, that are placed on CPU."
              " Got a GPU input .*in logical expression.*|"
              "Named arguments inputs to operators must be CPU data nodes."
              " However, a GPU data node was provided"
          ),
      ):
          pipe = gpu_input()
          pipe.build()
          pipe.run()
  
      @pipeline_def(**kwargs)
      def non_scalar_input():
          pred = fn.random.coin_flip(dtype=types.DALIDataType.BOOL)
          stacked = fn.stack(pred, pred)
          return expression(stacked)
  
      with assert_raises(
          RuntimeError,
          glob=(
              "Logical expression `*` is restricted to scalar (0-d tensors)"
              " inputs*, that are placed on CPU. Got a 1-d input"
              " *in logical expression."
          ),
      ):
          pipe = non_scalar_input()
          pipe.build()
          pipe.run()
  
file_path: DALI/dali/test/python/conditionals/test_logical_expressions.py
imports: from nvidia.dali.pipeline import pipeline_def
  import nvidia.dali.fn
  import nvidia.dali.types
  from test_utils import compare_pipelines, check_batch
  from nose_utils import assert_raises
  from nose2.tools import params
  import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: test_error_input(expression) and returns: expression, expression