class_docstr: DeviceContextStore provides thread-safe storage for EGL and pycuda contexts. It
  should not be used directly. opengl_utils instantiates a module-global variable
  called opengl_utils.global_device_context_store. MeshRasterizerOpenGL uses this
  store to avoid unnecessary context creation and destruction.
  
  The EGL/CUDA contexts are not meant to be created and destroyed all the time,
  and having multiple on a single device can be troublesome. Intended use is entirely
  transparent to the user::
  
      rasterizer1 = MeshRasterizerOpenGL(...some args...)
      mesh1 = load_mesh_on_cuda_0()
  
      # Now rasterizer1 will request EGL/CUDA contexts from
      # global_device_context_store on cuda:0, and since there aren't any, the
      # store will create new ones.
      rasterizer1.rasterize(mesh1)
  
      # rasterizer2 also needs EGL & CUDA contexts. But global_context_store
      # already has them for cuda:0. Instead of creating new contexts, the store
      # will tell rasterizer2 to use them.
      rasterizer2 = MeshRasterizerOpenGL(dcs)
      rasterize2.rasterize(mesh1)
  
      # When rasterizer1 needs to render on cuda:1, the store will create new contexts.
      mesh2 = load_mesh_on_cuda_1()
      rasterizer1.rasterize(mesh2)
class_docstr_tok: ["DeviceContextStore","provides","thread-safe","storage","for","EGL","and","pycuda","contexts",".","It","should","not","be","used","directly",".","opengl_utils","instantiates","a","module-global","variable","called","opengl_utils.global_device_context_store",".","MeshRasterizerOpenGL","uses","this","store","to","avoid","unnecessary","context","creation","and","destruction",".","The","EGL\/CUDA","contexts","are","not","meant","to","be","created","and","destroyed","all","the","time",",","and","having","multiple","on","a","single","device","can","be","troublesome",".","Intended","use","is","entirely","transparent","to","the","user",":",":","rasterizer1","=","MeshRasterizerOpenGL","(","...","some","args","...",")","mesh1","=","load_mesh_on_cuda_0","(",")","#","Now","rasterizer1","will","request","EGL\/CUDA","contexts","from","#","global_device_context_store","on","cuda:0",",","and","since","there","are","n't","any",",","the","#","store","will","create","new","ones",".","rasterizer1.rasterize","(","mesh1",")","#","rasterizer2","also","needs","EGL","&","CUDA","contexts",".","But","global_context_store","#","already","has","them","for","cuda:0",".","Instead","of","creating","new","contexts",",","the","store","#","will","tell","rasterizer2","to","use","them",".","rasterizer2","=","MeshRasterizerOpenGL","(","dcs",")","rasterize2.rasterize","(","mesh1",")","#","When","rasterizer1","needs","to","render","on","cuda:1",",","the","store","will","create","new","contexts",".","mesh2","=","load_mesh_on_cuda_1","(",")","rasterizer1.rasterize","(","mesh2",")"]
docstr: Get arbitrary data in a per-device dict. See set_context_data for more detail.
  
  Args:
      device: A torch.device
  
  Returns:
      The most recent object stored using set_context_data.
docstr_tok: ["Get","arbitrary","data","in","a","per-device","dict",".","See","set_context_data","for","more","detail",".","Args",":","device",":","A","torch.device","Returns",":","The","most","recent","object","stored","using","set_context_data","."]
code: def get_context_data(self, device):
      """
      Get arbitrary data in a per-device dict. See set_context_data for more detail.
  
      Args:
          device: A torch.device
  
      Returns:
          The most recent object stored using set_context_data.
      """
      cuda_device_id = device.index
      return self._context_data.get(cuda_device_id, None)
  
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 5 for calling the _DeviceContextStore obj's underlying member method code with example usage: obj.get_context_data(device) and returns: self