class_docstr: Module, which estimates the dominant gradient orientation of the given patches, in radians.
  
  Zero angle points towards right.
  
  Args:
      patch_size: size of the (square) input patch.
      num_angular_bins: number of histogram bins.
      eps: for safe division, and arctan.
class_docstr_tok: ["Module",",","which","estimates","the","dominant","gradient","orientation","of","the","given","patches",",","in","radians",".","Zero","angle","points","towards","right",".","Args",":","patch_size",":","size","of","the","(","square",")","input","patch",".","num_angular_bins",":","number","of","histogram","bins",".","eps",":","for","safe","division",",","and","arctan","."]
docstr: Args:
      patch: :math:`(B, 1, H, W)`
  
  Returns:
      angle in radians: :math:`(B)`
docstr_tok: ["Args",":","patch",":",":","math",":","`","(","B",",","1",",","H",",","W",")","`","Returns",":","angle","in","radians",":",":","math",":","`","(","B",")","`"]
code: def forward(self, patch: torch.Tensor) -> torch.Tensor:
      """
      Args:
          patch: :math:`(B, 1, H, W)`
  
      Returns:
          angle in radians: :math:`(B)`
      """
      KORNIA_CHECK_SHAPE(patch, ["B", "1", "H", "W"])
      _, CH, W, H = patch.size()
      if (W != self.patch_size) or (H != self.patch_size) or (CH != 1):
          raise TypeError(
              f"input shape should be must be [Bx1x{self.patch_size}x{self.patch_size}]. Got {patch.size()}"
          )
      self.weighting = self.weighting.to(patch.dtype).to(patch.device)
      self.angular_smooth = self.angular_smooth.to(patch.dtype).to(
          patch.device
      )
      grads: torch.Tensor = self.gradient(patch)
      # unpack the edges
      gx: torch.Tensor = grads[:, :, 0]
      gy: torch.Tensor = grads[:, :, 1]
  
      mag: torch.Tensor = (
          torch.sqrt(gx * gx + gy * gy + self.eps) * self.weighting
      )
      ori: torch.Tensor = torch.atan2(gy, gx + self.eps) + 2.0 * pi
  
      o_big = float(self.num_ang_bins) * (ori + 1.0 * pi) / (2.0 * pi)
      bo0_big = torch.floor(o_big)
      wo1_big = o_big - bo0_big
      bo0_big = bo0_big % self.num_ang_bins
      bo1_big = (bo0_big + 1) % self.num_ang_bins
      wo0_big = (1.0 - wo1_big) * mag
      wo1_big = wo1_big * mag
      ang_bins_list = []
      for i in range(0, self.num_ang_bins):
          ang_bins_i = F.adaptive_avg_pool2d(
              (bo0_big == i).to(patch.dtype) * wo0_big
              + (bo1_big == i).to(patch.dtype) * wo1_big,
              (1, 1),
          )
          ang_bins_list.append(ang_bins_i)
      ang_bins = torch.cat(ang_bins_list, 1).view(
          -1, 1, self.num_ang_bins
      )
      ang_bins = self.angular_smooth(ang_bins).view(
          -1, self.num_ang_bins
      )
      values, indices = ang_bins.max(1)
      indices_left = (
          self.num_ang_bins + indices - 1
      ) % self.num_ang_bins
      indices_right = (indices + 1) % self.num_ang_bins
      left = torch.gather(
          ang_bins, 1, indices_left.reshape(-1, 1)
      ).reshape(-1)
      center = values
      right = torch.gather(
          ang_bins, 1, indices_right.reshape(-1, 1)
      ).reshape(-1)
      c_subpix = 0.5 * (left - right) / (left + right - 2.0 * center)
      angle = -(
          (
              2.0
              * pi
              * (indices.to(patch.dtype) + c_subpix)
              / float(self.num_ang_bins)
          )
          - pi
      )
      return angle
  
imports: from typing import Dict, Optional
  import torch
  import torch.nn.functional
  from torch import nn
  from kornia.constants import pi
  from kornia.core.check import KORNIA_CHECK_LAF, KORNIA_CHECK_SHAPE
  from kornia.filters import SpatialGradient, get_gaussian_discrete_kernel1d, get_gaussian_kernel2d
  from kornia.geometry import rad2deg
  from kornia.utils.helpers import map_location_to_cpu
  from .laf import extract_patches_from_pyramid, get_laf_orientation, set_laf_orientation
label_desc: Use image node_id 3 for calling the PatchDominantGradientOrientation obj's underlying member method code with example usage: obj.forward(patch) and returns: angle