class_docstr: Module that computes explicit cartesian or polar embedding.
  
  Args:
      kernel_type: Parametrization of kernel ``'polar'`` or ``'cart'``.
      fmap_size: Input feature map size in pixels.
      in_dims: Dimensionality of input feature map.
      do_gmask: Apply gaussian mask.
      do_l2: Apply l2-normalization.
  
  Returns:
      Explicit cartesian or polar embedding.
  
  Shape:
      - Input: (B, in_dims, fmap_size, fmap_size)
      - Output: (B, out_dims, fmap_size, fmap_size)
  
  Example:
      >>> emb_ori = torch.rand(23, 7, 32, 32)
      >>> ese = ExplicitSpacialEncoding(kernel_type='polar',
      ...                               fmap_size=32,
      ...                               in_dims=7,
      ...                               do_gmask=True,
      ...                               do_l2=True)
      >>> desc = ese(emb_ori) # 23x175x32x32
class_docstr_tok: ["Module","that","computes","explicit","cartesian","or","polar","embedding",".","Args",":","kernel_type",":","Parametrization","of","kernel","``","'polar","'","``","or","``","'cart","'","``",".","fmap_size",":","Input","feature","map","size","in","pixels",".","in_dims",":","Dimensionality","of","input","feature","map",".","do_gmask",":","Apply","gaussian","mask",".","do_l2",":","Apply","l2-normalization",".","Returns",":","Explicit","cartesian","or","polar","embedding",".","Shape",":","-","Input",":","(","B",",","in_dims",",","fmap_size",",","fmap_size",")","-","Output",":","(","B",",","out_dims",",","fmap_size",",","fmap_size",")","Example",":",">",">",">","emb_ori","=","torch.rand","(","23",",","7",",","32",",","32",")",">",">",">","ese","=","ExplicitSpacialEncoding","(","kernel_type='polar","'",",","...","fmap_size=32",",","...","in_dims=7",",","...","do_gmask=True",",","...","do_l2=True",")",">",">",">","desc","=","ese","(","emb_ori",")","#","23x175x32x32"]
code: def forward(self, x: Tensor) -> Tensor:
      if not isinstance(x, Tensor):
          raise TypeError(f"Input type is not a Tensor. Got {type(x)}")
      if not ((len(x.shape) == 4) | (x.shape[1] == self.in_dims)):
          raise ValueError(
              f"Invalid input shape, we expect Bx{self.in_dims}xHxW. Got: {x.shape}"
          )
      idx1 = torch.jit.annotate(Tensor, self.idx1)
      emb1 = torch.index_select(x, 1, idx1)
      output = emb1 * self.emb2
      output = output.sum(dim=(2, 3))
      if self.do_l2:
          output = F.normalize(output, dim=1)
      return output
  
imports: from typing import Any, Dict, List, Tuple, Union
  import torch
  import torch.nn.functional
  from torch import nn
  from kornia.constants import pi
  from kornia.core import Tensor, cos, sin, tensor, zeros
  from kornia.filters import GaussianBlur2d, SpatialGradient
  from kornia.geometry.conversions import cart2pol
  from kornia.utils import create_meshgrid
  from kornia.utils.helpers import map_location_to_cpu
label_desc: Use image node_id 4 for calling the ExplicitSpacialEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: output