code: def _get_egl_config(egl_dpy, surface_type):
      """
      Get an EGL config with reasonable settings (for use with MeshRasterizerOpenGL).
  
      Args:
          egl_dpy: An EGL display constant (int).
          surface_type: An EGL surface_type int.
  
      Returns:
          An EGL config object.
  
      Throws:
          ValueError if the desired config is not available or invalid.
      """
      egl_config_dict = {
          egl.EGL_RED_SIZE: 8,
          egl.EGL_GREEN_SIZE: 8,
          egl.EGL_BLUE_SIZE: 8,
          egl.EGL_ALPHA_SIZE: 8,
          egl.EGL_DEPTH_SIZE: 24,
          egl.EGL_STENCIL_SIZE: egl.EGL_DONT_CARE,
          egl.EGL_RENDERABLE_TYPE: egl.EGL_OPENGL_BIT,
          egl.EGL_SURFACE_TYPE: surface_type,
      }
      egl_config_array = _egl_convert_to_int_array(egl_config_dict)
      egl_config = egl.EGLConfig()
      num_configs = egl.EGLint()
      if (
          not egl.eglChooseConfig(
              egl_dpy,
              egl_config_array,
              ctypes.pointer(egl_config),
              1,
              ctypes.pointer(num_configs),
          )
          or num_configs.value == 0
      ):
          raise ValueError("Invalid EGL config.")
      return egl_config
  
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 4 for calling a global function with example usage: _get_egl_config(egl_dpy, surface_type) and returns: egl_config