code: def selected(
      objects: Union[bpy.types.Object, Sequence[bpy.types.Object]]
  ):
      """Contextmanager to select objects and to restore the prior selection after.
  
      Selects all provided objects and marks the first one as active for the duration
      of the context. Afterwards it restores the previous selection and active object.
  
      Args:
        objects:  Either a single object or a sequence of objects to select.
      """
      if not isinstance(objects, Sequence):
          objects = [objects]
      previous_selection = copy.copy(bpy.context.selected_objects)
      previous_active = bpy.context.active_object
  
      for obj in bpy.context.selected_objects:
          obj.select_set(False)  # deselect everything
      for obj in objects:
          obj.select_set(True)  # select target objects
      # set the active object to the first obj in obj_list
      bpy.context.view_layer.objects.active = objects[0]
  
      yield
  
      for obj in bpy.context.selected_objects:
          obj.select_set(False)  # deselect everything
      for obj in previous_selection:
          obj.select_set(True)  # re-select previous selected objects
      # re-activate previous object
      bpy.context.view_layer.objects.active = previous_active
  
imports: import contextlib
  import copy
  import functools
  import sys
  from typing import Dict, Sequence, Tuple, Union
  import numpy
  import OpenEXR
  import Imath
  import sklearn.utils
  import trimesh
  from kubric import core
  from kubric.kubric_typing import AddAssetFunction, ArrayLike
  from kubric.redirect_io import RedirectStream
  from kubric.safeimport.bpy import bpy
label_desc: Use image node_id 10 for calling a global function with example usage: selected(objects) without return types