code: def set_up_exr_output_node(
      default_layers=("Image", "Depth"),
      aux_layers=(
          "UV",
          "Normal",
          "CryptoObject00",
          "ObjectCoordinates",
      ),
      motion_blur=None,
  ):
      """Set up the blender compositor nodes required for exporting EXR files.
  
      The filename can then be set with:
      out_node.base_path = "my/custom/path/prefix_"
  
      """
      bpy.context.scene.use_nodes = True
      tree = bpy.context.scene.node_tree
      links = tree.links
  
      # clear existing nodes
      for node in tree.nodes:
          tree.nodes.remove(node)
  
      # the render node has outputs for all the rendered layers
      render_node = tree.nodes.new(type="CompositorNodeRLayers")
      render_node_aux = tree.nodes.new(type="CompositorNodeRLayers")
      render_node_aux.name = "Render Layers Aux"
      render_node_aux.layer = "AuxOutputs"
  
      # create a new FileOutput node
      out_node = tree.nodes.new(type="CompositorNodeOutputFile")
      # set the format to EXR (multilayer)
      out_node.format.file_format = "OPEN_EXR_MULTILAYER"
  
      out_node.file_slots.clear()
      for layer_name in default_layers:
          out_node.file_slots.new(layer_name)
          links.new(
              render_node.outputs.get(layer_name),
              out_node.inputs.get(layer_name),
          )
  
      for layer_name in aux_layers:
          out_node.file_slots.new(layer_name)
          links.new(
              render_node_aux.outputs.get(layer_name),
              out_node.inputs.get(layer_name),
          )
  
      # manually convert to RGBA. See:
      # https://blender.stackexchange.com/questions/175621/incorrect-vector-pass-output-no-alpha-zero-values/175646#175646
      split_rgba = tree.nodes.new(type="CompositorNodeSepRGBA")
      combine_rgba = tree.nodes.new(type="CompositorNodeCombRGBA")
      for channel in "RGBA":
          links.new(
              split_rgba.outputs.get(channel),
              combine_rgba.inputs.get(channel),
          )
      out_node.file_slots.new("Vector")
      links.new(
          render_node_aux.outputs.get("Vector"),
          split_rgba.inputs.get("Image"),
      )
      links.new(
          combine_rgba.outputs.get("Image"),
          out_node.inputs.get("Vector"),
      )
  
      if motion_blur is not None:
          assert isinstance(motion_blur, float), motion_blur
          # we then add a vector blur that uses optical flow to blur the image
          motion_blur_node = tree.nodes.new(
              type="CompositorNodeVecBlur"
          )
          composite_out = tree.nodes.new(type="CompositorNodeComposite")
          motion_blur_node.factor = motion_blur
          motion_blur_node.use_curved = True
          links.new(
              render_node.outputs.get("Image"),
              motion_blur_node.inputs.get("Image"),
          )
          links.new(
              render_node.outputs.get("Depth"),
              motion_blur_node.inputs.get("Z"),
          )
          links.new(
              render_node_aux.outputs.get("Vector"),
              motion_blur_node.inputs.get("Speed"),
          )
          links.remove(out_node.inputs.get("Image").links[0])
          links.new(
              motion_blur_node.outputs.get("Image"),
              out_node.inputs.get("Image"),
          )
          links.new(
              motion_blur_node.outputs.get("Image"),
              composite_out.inputs.get("Image"),
          )
  
      return out_node
  
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 3 for calling a global function with example usage: set_up_exr_output_node(default_layers, aux_layers, motion_blur) and returns: out_node