code: def rgb_to_raw(image: torch.Tensor, cfa: CFA) -> torch.Tensor:
      r"""Convert a RGB image to RAW version of image with the specified color filter array.
  
      The image data is assumed to be in the range of (0, 1).
  
      Args:
          image: RGB image to be converted to bayer raw with shape :math:`(*,3,H,W)`.
          cfa: Which color filter array do we want the output to mimic. I.e. which pixels are red/green/blue.
  
      Returns:
          raw version of the image with shape :math:`(*,1,H,W)`.
  
      Example:
          >>> rgbinput = torch.rand(2, 3, 4, 6)
          >>> raw = rgb_to_raw(rgbinput, CFA.BG) # 2x1x4x6
      """
      if not isinstance(image, torch.Tensor):
          raise TypeError(
              f"Input type is not a torch.Tensor. Got {type(image)}"
          )
  
      if len(image.shape) < 3 or image.shape[-3] != 3:
          raise ValueError(
              f"Input size must have a shape of (*, 3, H, W). Got {image.shape}"
          )
  
      # pick the tensor with green pixels
      # clone to make sure grad works
      output: torch.Tensor = image[..., 1:2, :, :].clone()
  
      # overwrite the r/b positions (depending on the cfa configuration) with blue/red pixels
      if cfa == CFA.BG:
          output[..., :, ::2, ::2] = image[..., 0:1, ::2, ::2]  # red
          output[..., :, 1::2, 1::2] = image[
              ..., 2:3, 1::2, 1::2
          ]  # blue
      elif cfa == CFA.GB:
          output[..., :, ::2, 1::2] = image[..., 0:1, ::2, 1::2]  # red
          output[..., :, 1::2, ::2] = image[..., 2:3, 1::2, ::2]  # blue
      elif cfa == CFA.RG:
          output[..., :, 1::2, 1::2] = image[
              ..., 0:1, 1::2, 1::2
          ]  # red
          output[..., :, ::2, ::2] = image[..., 2:3, ::2, ::2]  # blue
      elif cfa == CFA.GR:
          output[..., :, 1::2, ::2] = image[..., 0:1, 1::2, ::2]  # red
          output[..., :, ::2, 1::2] = image[..., 2:3, ::2, 1::2]  # blue
  
      return output
  
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 2 for calling a global function with example usage: rgb_to_raw(image, cfa) and returns: output