code: def _lut(image, lut):
      if image.mode == "P":
          # FIXME: apply to lookup table, not image data
          msg = "mode P support coming soon"
          raise NotImplementedError(msg)
      elif image.mode in ("L", "RGB"):
          if image.mode == "RGB" and len(lut) == 256:
              lut = lut + lut + lut
          return image.point(lut)
      else:
          msg = f"not supported for mode {image.mode}"
          raise OSError(msg)
  
imports: from __future__ import annotations
  import functools
  import operator
  import re
  from .None import ExifTags, Image, ImagePalette
label_desc: Use image node_id 3 for calling a global function with example usage: _lut(image, lut) and returns: image