code: def test_int_ptr(ctx_factory):
      def do_test(obj):
          new_obj = type(obj).from_int_ptr(obj.int_ptr)
          assert obj == new_obj
          assert type(obj) is type(new_obj)
  
      ctx = ctx_factory()
      (device,) = ctx.devices
      platform = device.platform
      do_test(device)
      do_test(platform)
      do_test(ctx)
  
      queue = cl.CommandQueue(ctx)
      do_test(queue)
  
      evt = cl.enqueue_marker(queue)
      do_test(evt)
  
      prg = cl.Program(
          ctx,
          """
          __kernel void sum(__global float *a)
          { a[get_global_id(0)] *= 2; }
          """,
      ).build()
  
      do_test(prg)
      do_test(prg.sum)
  
      n = 2000
      a_buf = cl.Buffer(ctx, 0, n * 4)
      do_test(a_buf)
  
      # crashes on intel...
      # and pocl does not support CL_ADDRESS_CLAMP
      if device.image_support and platform.vendor not in [
          "Intel(R) Corporation",
          "The pocl project",
      ]:
          smp = cl.Sampler(
              ctx,
              False,
              cl.addressing_mode.CLAMP,
              cl.filter_mode.NEAREST,
          )
          do_test(smp)
  
          img_format = cl.get_supported_image_formats(
              ctx, cl.mem_flags.READ_ONLY, cl.mem_object_type.IMAGE2D
          )[0]
  
          img = cl.Image(
              ctx, cl.mem_flags.READ_ONLY, img_format, (128, 256)
          )
          do_test(img)
  
imports: import numpy
  import numpy.linalg
  import pytest
  import pyopencl
  import pyopencl.array
  import pyopencl.cltypes
  import pyopencl.clrandom
  from pyopencl.tools import pytest_generate_tests_for_pyopencl, ImmediateAllocator, DeferredAllocator
  from pyopencl.characterize import get_pocl_version
label_desc: Use image node_id 4 for calling a global function with example usage: test_int_ptr(ctx_factory) without return types