code: def _maybe_process_in_chunks(
      process_fn: Callable[Concatenate[np.ndarray, P], np.ndarray],
      **kwargs,
  ) -> Callable[[np.ndarray], np.ndarray]:
      """
      Wrap OpenCV function to enable processing images with more than 4 channels.
  
      Limitations:
          This wrapper requires image to be the first argument and rest must be sent via named arguments.
  
      Args:
          process_fn: Transform function (e.g cv2.resize).
          kwargs: Additional parameters.
  
      Returns:
          numpy.ndarray: Transformed image.
  
      """
  
      @wraps(process_fn)
      def __process_fn(img: np.ndarray) -> np.ndarray:
          num_channels = get_num_channels(img)
          if num_channels > 4:
              chunks = []
              for index in range(0, num_channels, 4):
                  if num_channels - index == 2:
                      # Many OpenCV functions cannot work with 2-channel images
                      for i in range(2):
                          chunk = img[:, :, index + i : index + i + 1]
                          chunk = process_fn(chunk, **kwargs)
                          chunk = np.expand_dims(chunk, -1)
                          chunks.append(chunk)
                  else:
                      chunk = img[:, :, index : index + 4]
                      chunk = process_fn(chunk, **kwargs)
                      chunks.append(chunk)
              img = np.dstack(chunks)
          else:
              img = process_fn(img, **kwargs)
          return img
  
      return __process_fn
  
imports: from functools import wraps
  from typing import Callable, Union
  import cv2
  import numpy
  from typing_extensions import Concatenate, ParamSpec
  from albumentations.core.keypoints_utils import angle_to_2pi_range
  from albumentations.core.transforms_interface import KeypointInternalType
label_desc: Use image node_id 15 for calling a global function with example usage: _maybe_process_in_chunks(process_fn) and returns: __process_fn, img