code: def _define_egl_extension(name: str, type):
      if hasattr(egl, name):
          return
      addr = egl.eglGetProcAddress(name)
      if addr is None:
          raise RuntimeError(f"Cannot find EGL extension {name}.")
      else:
          proto = ctypes.CFUNCTYPE(type)
          func = proto(addr)
          setattr(egl, name, func)
      return proto
  
imports: import contextlib
  import ctypes
  import os
  import threading
  from typing import Any, Dict
  import OpenGL.EGL
  import pycuda.driver
  from OpenGL._opaque import opaque_pointer_cls
  from OpenGL.raw.EGL._errors import EGLError
label_desc: Use image node_id 1 for calling a global function with example usage: _define_egl_extension(name, type) and returns: proto