code: def ref_cast(x, dtype):
      if np.issubdtype(dtype, np.integer):
          lo = np.iinfo(dtype).min
          hi = np.iinfo(dtype).max
          if np.issubdtype(x.dtype, np.floating):
              x = np.round(x)
          return x.clip(lo, hi).astype(dtype)
      else:
          return x.astype(dtype)
  
file_path: DALI/dali/test/python/operator_1/test_cast.py
imports: import numpy
  import nvidia.dali.fn
  import nvidia.dali.types
  from nose.tools import nottest
  from nvidia.dali import pipeline_def
  from test_utils import np_type_to_dali
  import itertools
  from nose2.tools import params
label_desc: Use image node_id 1 for calling a global function with example usage: ref_cast(x, dtype) and returns: x, x