code: def make_py_capsule(managed):
      if not isinstance(managed, DLManagedTensor):
          managed = make_dl_managed_tensor(managed)
      pointer = ctypes.pointer(managed)
      capsule = PyCapsule_New(
          pointer, b"dltensor", py_capsule_destructor
      )
      context = make_py_context(managed)
      PyCapsule_SetContext(capsule, context)
      return capsule
  
imports: import sys
  import ctypes
  from enum import IntEnum
label_desc: Use image node_id 9 for calling a global function with example usage: make_py_capsule(managed) and returns: capsule