code: def generate(
      rng,
      ndim: int,
      batch_size: int,
      in_dtype: np.dtype,
      out_dtype: np.dtype,
      empty_volume_policy: str,
  ):
      lo, hi = -1000, 1000
      if np.issubdtype(out_dtype, np.integer):
          lo = np.iinfo(out_dtype).min
          hi = np.iinfo(out_dtype).max
          if hi < np.iinfo(np.int64).max:
              r = hi - lo
              hi += r // 2
              lo -= r // 2
          if np.issubdtype(in_dtype, np.integer):
              lo = max(np.iinfo(in_dtype).min, lo)
              hi = min(np.iinfo(in_dtype).max, hi)
          else:
              lo = max(-np.finfo(in_dtype).max, lo)
              hi = min(np.finfo(in_dtype).max, hi)
  
      max_size = 100000 // batch_size
      out = [
          rng.uniform(
              lo, hi, size=random_shape(rng, ndim, max_size)
          ).astype(in_dtype)
          for _ in range(batch_size)
      ]
      out = replace_with_empty_volumes(rng, out, empty_volume_policy)
      if np.issubdtype(in_dtype, np.floating) and np.issubdtype(
          out_dtype, np.integer
      ):
          for x in out:
              # avoid exactly halfway numbers - rounding is different for CPU and GPU
              halfway = x[x - np.floor(x) == 0.5]
              x[x - np.floor(x) == 0.5] = np.nextafter(
                  halfway, np.Infinity
              )
      return out
  
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 4 for calling a global function with example usage: generate(rng, ndim, batch_size, in_dtype, out_dtype, empty_volume_policy) and returns: out