code: def get_correlation(
      left_feature: Tensor,
      right_feature: Tensor,
      window_size: Tuple[int, int] = (3, 3),
      dilate: Tuple[int, int] = (1, 1),
  ) -> Tensor:
      """Function that computes a correlation product between the left and right features.
  
      The correlation is computed in a sliding window fashion, namely the left features are fixed
      and for each ``(i, j)`` location we compute the correlation with a sliding window anchored in
      ``(i, j)`` from the right feature map. The sliding window selects pixels obtained in the range of the sliding
      window; i.e ``(i - window_size // 2, i + window_size // 2)`` respectively ``(j - window_size // 2, j + window_size // 2)``.
      """
  
      B, C, H, W = left_feature.shape
  
      di_y, di_x = dilate[0], dilate[1]
      pad_y, pad_x = (
          window_size[0] // 2 * di_y,
          window_size[1] // 2 * di_x,
      )
  
      right_padded = F.pad(
          right_feature, (pad_x, pad_x, pad_y, pad_y), mode="replicate"
      )
      # in order to vectorize the correlation computation over all pixel candidates
      # we create multiple shifted right images which we stack on an extra dimension
      right_padded = F.unfold(
          right_padded, kernel_size=(H, W), dilation=dilate
      )
      # torch unfold returns a tensor of shape [B, flattened_values, n_selections]
      right_padded = right_padded.permute(0, 2, 1)
      # we consider rehsape back into [B, n_views, C, H, W]
      right_padded = right_padded.reshape(
          B, (window_size[0] * window_size[1]), C, H, W
      )
      # we expand the left features for broadcasting
      left_feature = left_feature.unsqueeze(1)
      # this will compute an element product of between [B, 1, C, H, W] * [B, n_views, C, H, W]
      # to obtain correlations over the pixel candidates we perform a mean on the C dimension
      correlation = torch.mean(
          left_feature * right_padded, dim=2, keepdim=False
      )
      # the final correlation tensor shape will be [B, n_views, H, W]
      # where on the i-th position of the n_views dimension we will have
      # the correlation value between the left pixel
      # and the i-th candidate on the right feature map
      return correlation
  
imports: import math
  from functools import partial
  from typing import Callable, Dict, Iterable, List, Optional, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torchvision.models.optical_flow.raft
  from torch import Tensor
  from torchvision.models._api import register_model, Weights, WeightsEnum
  from torchvision.models._utils import handle_legacy_interface
  from torchvision.models.optical_flow._utils import grid_sample, make_coords_grid, upsample_flow
  from torchvision.ops import Conv2dNormActivation
  from torchvision.prototype.transforms._presets import StereoMatching
label_desc: Use image node_id 1 for calling a global function with example usage: get_correlation(left_feature, right_feature, window_size, dilate) and returns: correlation