class_docstr: Performs a weighted aggregation using a set of predefined `reduction_functions`
  and concatenates the results of each aggregation function along the
  channel dimension. The weights are proportional to the cosine of the
  angle between the target ray and the source ray::
  
      weight = (
          dot(target_ray, source_ray) * 0.5 + 0.5 + self.min_ray_angle_weight
      )**self.weight_by_ray_angle_gamma
  
  The reduction functions singularize the second dimension
  of the sampled features which stacks the source views.
  
  Settings:
      reduction_functions: A list of `ReductionFunction`s that reduce the
          the stack of source-view-specific features to a single feature.
      min_ray_angle_weight: The minimum possible aggregation weight
          before rasising to the power of `self.weight_by_ray_angle_gamma`.
      weight_by_ray_angle_gamma: The exponent of the cosine of the ray angles
          used when calculating the angle-based aggregation weights.
class_docstr_tok: ["Performs","a","weighted","aggregation","using","a","set","of","predefined","`","reduction_functions","`","and","concatenates","the","results","of","each","aggregation","function","along","the","channel","dimension",".","The","weights","are","proportional","to","the","cosine","of","the","angle","between","the","target","ray","and","the","source","ray",":",":","weight","=","(","dot","(","target_ray",",","source_ray",")","*","0.5","+","0.5","+","self.min_ray_angle_weight",")","*","*","self.weight_by_ray_angle_gamma","The","reduction","functions","singularize","the","second","dimension","of","the","sampled","features","which","stacks","the","source","views",".","Settings",":","reduction_functions",":","A","list","of","`","ReductionFunction","`","s","that","reduce","the","the","stack","of","source-view-specific","features","to","a","single","feature",".","min_ray_angle_weight",":","The","minimum","possible","aggregation","weight","before","rasising","to","the","power","of","`","self.weight_by_ray_angle_gamma","`",".","weight_by_ray_angle_gamma",":","The","exponent","of","the","cosine","of","the","ray","angles","used","when","calculating","the","angle-based","aggregation","weights","."]
docstr: Args:
      feats_sampled: A `dict` of sampled feature tensors `{f_i: t_i}`,
          where each `t_i` is a tensor of shape
          `(minibatch, n_source_views, n_samples, dim_i)`.
      masks_sampled: A binary mask represented as a tensor of shape
          `(minibatch, n_source_views, n_samples, 1)` denoting valid
          sampled features.
      camera: A batch of `n_source_views` `CamerasBase` objects
          corresponding to the source view cameras.
      pts: A tensor of shape `(minibatch, n_samples, 3)` denoting the
          3D points whose 2D projections to source views were sampled in
          order to generate `feats_sampled` and `masks_sampled`.
  
  Returns:
      feats_aggregated: If `concatenate_output==True`, a tensor
          of shape `(minibatch, 1, n_samples, sum(dim_1, ... dim_N))`.
          If `concatenate_output==False`, a dictionary `{f_i: t_i_aggregated}`
          with each `t_i_aggregated` of shape
          `(minibatch, n_source_views, n_samples, dim_i)`.
docstr_tok: ["Args",":","feats_sampled",":","A","`","dict","`","of","sampled","feature","tensors","`","{","f_i",":","t_i","}","`",",","where","each","`","t_i","`","is","a","tensor","of","shape","`","(","minibatch",",","n_source_views",",","n_samples",",","dim_i",")","`",".","masks_sampled",":","A","binary","mask","represented","as","a","tensor","of","shape","`","(","minibatch",",","n_source_views",",","n_samples",",","1",")","`","denoting","valid","sampled","features",".","camera",":","A","batch","of","`","n_source_views","`","`","CamerasBase","`","objects","corresponding","to","the","source","view","cameras",".","pts",":","A","tensor","of","shape","`","(","minibatch",",","n_samples",",","3",")","`","denoting","the","3D","points","whose","2D","projections","to","source","views","were","sampled","in","order","to","generate","`","feats_sampled","`","and","`","masks_sampled","`",".","Returns",":","feats_aggregated",":","If","`","concatenate_output==True","`",",","a","tensor","of","shape","`","(","minibatch",",","1",",","n_samples",",","sum","(","dim_1",",","...","dim_N",")",")","`",".","If","`","concatenate_output==False","`",",","a","dictionary","`","{","f_i",":","t_i_aggregated","}","`","with","each","`","t_i_aggregated","`","of","shape","`","(","minibatch",",","n_source_views",",","n_samples",",","dim_i",")","`","."]
code: def forward(
      self,
      feats_sampled: Dict[str, torch.Tensor],
      masks_sampled: torch.Tensor,
      camera: Optional[CamerasBase] = None,
      pts: Optional[torch.Tensor] = None,
      **kwargs,
  ) -> Union[torch.Tensor, Dict[str, torch.Tensor]]:
      """
      Args:
          feats_sampled: A `dict` of sampled feature tensors `{f_i: t_i}`,
              where each `t_i` is a tensor of shape
              `(minibatch, n_source_views, n_samples, dim_i)`.
          masks_sampled: A binary mask represented as a tensor of shape
              `(minibatch, n_source_views, n_samples, 1)` denoting valid
              sampled features.
          camera: A batch of `n_source_views` `CamerasBase` objects
              corresponding to the source view cameras.
          pts: A tensor of shape `(minibatch, n_samples, 3)` denoting the
              3D points whose 2D projections to source views were sampled in
              order to generate `feats_sampled` and `masks_sampled`.
  
      Returns:
          feats_aggregated: If `concatenate_output==True`, a tensor
              of shape `(minibatch, 1, n_samples, sum(dim_1, ... dim_N))`.
              If `concatenate_output==False`, a dictionary `{f_i: t_i_aggregated}`
              with each `t_i_aggregated` of shape
              `(minibatch, n_source_views, n_samples, dim_i)`.
      """
  
      if camera is None:
          raise ValueError(
              "camera cannot be None for angle weighted aggregation"
          )
  
      if pts is None:
          raise ValueError(
              "Points cannot be None for angle weighted aggregation"
          )
  
      pts_batch, n_cameras = masks_sampled.shape[:2]
      if self.exclude_target_view_mask_features:
          feats_sampled = _mask_target_view_features(feats_sampled)
      view_sampling_mask = _get_view_sampling_mask(
          n_cameras,
          pts_batch,
          masks_sampled.device,
          self.exclude_target_view,
      )
      aggr_weights = _get_angular_reduction_weights(
          view_sampling_mask,
          masks_sampled,
          camera,
          pts,
          self.min_ray_angle_weight,
          self.weight_by_ray_angle_gamma,
      )
      assert torch.isfinite(aggr_weights).all()
      feats_aggregated = {
          k: _avgmaxstd_reduction_function(
              f,
              aggr_weights,
              dim=1,
              reduction_functions=self.reduction_functions,
          )
          for k, f in feats_sampled.items()
      }
      if self.concatenate_output:
          feats_aggregated = torch.cat(
              tuple(feats_aggregated.values()), dim=-1
          )
      return feats_aggregated
  
imports: from abc import ABC, abstractmethod
  from enum import Enum
  from typing import Dict, Optional, Sequence, Tuple, Union
  import torch
  import torch.nn.functional
  from pytorch3d.implicitron.models.view_pooler.view_sampler import cameras_points_cartesian_product
  from pytorch3d.implicitron.tools.config import registry, ReplaceableBase
  from pytorch3d.ops import wmean
  from pytorch3d.renderer.cameras import CamerasBase
label_desc: Use image node_id 2 for calling the AngleWeightedReductionFeatureAggregator obj's underlying member method code with example usage: obj.forward(feats_sampled, masks_sampled, camera, pts) and returns: feats_aggregated