code: def setup_cupy():
      global cupy
      global cupy_stream
      global square_diff_kernel
      global mix_channels_kernel
      global gray_scale_kernel
      import cupy as cupy
  
      cupy_stream = cupy.cuda.Stream()
      square_diff_kernel = cupy.ElementwiseKernel(
          "T x, T y", "T z", "z = x*x - y*y", "square_diff"
      )
  
      mix_channels_kernel = cupy.ElementwiseKernel(
          "uint8 x, uint8 y",
          "uint8 z",
          "z = (i % 3) ? x : y",
          "mix_channels",
      )
  
      gray_scale_kernel = cupy.RawKernel(
          r"""
      extern "C" __global__
      void gray_scale(float *output, const unsigned char *input, long long height, long long width) {
          int tidx = blockIdx.x * blockDim.x + threadIdx.x;
          int tidy = blockIdx.y * blockDim.y + threadIdx.y;
          if (tidx < width && tidy < height) {
              float r = input[tidy * width + tidx] / 255.;
              float g = input[tidy * width + tidx + 1] / 255.;
              float b = input[tidy * width + tidx + 2] / 255.;
              output[tidy * width + tidx] = 0.299 * r + 0.59 * g + 0.11 * b;
          }
      }
      """,
          "gray_scale",
      )
  
imports: import numpy
  import nvidia.dali.ops
  import nvidia.dali.types
  import os
  import random
  from functools import partial
  from nvidia.dali.pipeline import Pipeline
  from nvidia.dali import fn, pipeline_def
  from nvidia.dali.python_function_plugin import current_dali_stream
label_desc: Use image node_id 3 for calling a global function with example usage: setup_cupy() without return types