class_docstr: Feature Encoder for Raft-Stereo (see paper section 3.1) that may have shared weight with the Context Encoder.
  
  The FeatureEncoder takes concatenation of left and right image as input. It produces feature embedding that later
  will be used to construct correlation volume.
class_docstr_tok: ["Feature","Encoder","for","Raft-Stereo","(","see","paper","section","3.1",")","that","may","have","shared","weight","with","the","Context","Encoder",".","The","FeatureEncoder","takes","concatenation","of","left","and","right","image","as","input",".","It","produces","feature","embedding","that","later","will","be","used","to","construct","correlation","volume","."]
code: def __init__(
      self,
      base_encoder: BaseEncoder,
      output_dim: int = 256,
      shared_base: bool = False,
      block: Callable[..., nn.Module] = ResidualBlock,
  ):
      super().__init__()
      self.base_encoder = base_encoder
      self.base_downsampling_ratio = base_encoder.downsampling_ratio
      base_dim = base_encoder.output_dim
  
      if not shared_base:
          self.residual_block: nn.Module = nn.Identity()
          self.conv = nn.Conv2d(base_dim, output_dim, kernel_size=1)
      else:
          # If we share base encoder weight for Feature and Context Encoder
          # we need to add residual block with InstanceNorm2d and change the kernel size for conv layer
          # see: https://github.com/princeton-vl/RAFT-Stereo/blob/main/core/raft_stereo.py#L35-L37
          self.residual_block = block(
              base_dim, base_dim, norm_layer=nn.InstanceNorm2d, stride=1
          )
          self.conv = nn.Conv2d(
              base_dim, output_dim, kernel_size=3, padding=1
          )
  
imports: from functools import partial
  from typing import Callable, List, Optional, Tuple
  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.models.optical_flow.raft import FlowHead, MotionEncoder, ResidualBlock
  from torchvision.ops import Conv2dNormActivation
  from torchvision.prototype.transforms._presets import StereoMatching
  from torchvision.utils import _log_api_usage_once
label_desc: Use image node_id 1 to create a new FeatureEncoder object from inherited base classes: nn with example: obj = FeatureEncoder(base_encoder, output_dim, shared_base, block)