code: def raw_to_rgb_2x2_downscaled(image: Tensor, cfa: CFA) -> Tensor:
      r"""Convert the raw bayer image to RGB version of it and resize width and height by half.
  
      This is done efficiently by converting each superpixel of bayer image to the corresponding rgb triplet.
      R and B channels of the raw image are left as are, while two G channels of raw image are averaged to obtain the
      output G channel.
  
      We are assuming a CFA with 2 green, 1 red, 1 blue.
      The image data is assumed to be in the range of (0, 1). Image H/W is assumed to be evenly divisible by 2
      for simplicity reasons.
  
      Args:
          image: raw image to be converted to RGB and downscaled with shape :math:`(*,1,H,W)`.
          cfa: The configuration of the color filter.
  
      Returns:
          downscaled RGB version of the image with shape :math:`(*,3,\frac{H}{2},\frac{W}{2})`.
  
      Example:
          >>> rawinput = torch.randn(2, 1, 4, 6)
          >>> rgb = raw_to_rgb_2x2_downscaled(rawinput, CFA.RG) # 2x3x2x3
      """
      KORNIA_CHECK(
          isinstance(image, Tensor), "Input type is not a torch.Tensor"
      )
  
      KORNIA_CHECK_SHAPE(image, ["*", "1", "H", "W"])
  
      KORNIA_CHECK(
          image.shape[-2] % 2 == 0 and image.shape[-1] % 2 == 0,
          f"Input H&W must be evenly disible by 2. Got {image.shape}",
      )
  
      if cfa == CFA.BG:
          r = image[..., :, ::2, ::2]
          b = image[..., :, 1::2, 1::2]
          g1 = image[..., :, ::2, 1::2]
          g2 = image[..., :, 1::2, ::2]
      elif cfa == CFA.GB:
          r = image[..., :, ::2, 1::2]
          b = image[..., :, 1::2, ::2]
          g1 = image[..., :, ::2, ::2]
          g2 = image[..., :, 1::2, 1::2]
      elif cfa == CFA.RG:
          r = image[..., :, 1::2, 1::2]
          b = image[..., :, ::2, ::2]
          g1 = image[..., :, 1::2, ::2]
          g2 = image[..., :, ::2, 1::2]
      elif cfa == CFA.GR:
          r = image[..., :, 1::2, ::2]
          b = image[..., :, ::2, 1::2]
          g1 = image[..., :, 1::2, 1::2]
          g2 = image[..., :, ::2, ::2]
      else:
          raise ValueError(f"Unsupported CFA Got {cfa}.")
  
      rgb: Tensor = concatenate([r, (g1 + g2) / 2, b], dim=-3)
  
      return rgb
  
imports: from enum import Enum
  import torch
  from torch import nn
  from kornia.core import Module, Tensor, concatenate
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_SHAPE
label_desc: Use image node_id 3 for calling a global function with example usage: raw_to_rgb_2x2_downscaled(image, cfa) and returns: rgb