code: def write_exr(filename, values, channel_names):
      """Writes the values in a multi-channel ndarray into an EXR file.
  
      Args:
        filename: The filename of the output file
        values: A numpy ndarray with shape [height, width, channels]
        channel_names: A list of strings with length = channels
  
      Raises:
        TypeError: If the numpy array has an unsupported type.
        ValueError: If the length of the array and the length of the channel names
          list do not match.
      """
      if values.shape[-1] != len(channel_names):
          raise ValueError(
              "Number of channels in values does not match channel names (%d, %d)"
              % (values.shape[-1], len(channel_names))
          )
      header = OpenEXR.Header(values.shape[1], values.shape[0])
      try:
          exr_channel_type = Imath.PixelType(
              _np_to_exr[values.dtype.type]
          )
      except KeyError:
          raise TypeError(
              "Unsupported numpy type: %s" % str(values.dtype)
          )
      header["channels"] = {
          n: Imath.Channel(exr_channel_type) for n in channel_names
      }
      channel_data = [values[..., i] for i in range(values.shape[-1])]
      exr = OpenEXR.OutputFile(filename, header)
      exr.writePixels(
          dict(
              (n, d.tobytes())
              for n, d in zip(channel_names, channel_data)
          )
      )
      exr.close()
  
file_path: graphics/tensorflow_graphics/io/exr.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import Imath
  import numpy
  import OpenEXR
  from six.moves import range
  from six.moves import zip
label_desc: Use image node_id 3 for calling a global function with example usage: write_exr(filename, values, channel_names) without return types