class_docstr: Positional encoding using random spatial frequencies.
docstr: Positionally encode points that are normalized to [0,1].
docstr_tok: ["Positionally","encode","points","that","are","normalized","to","[","0,1","]","."]
code: def _pe_encoding(self, coords: Tensor) -> Tensor:
      """Positionally encode points that are normalized to [0,1]."""
      # assuming coords are in [0, 1]^2 square and have d_1 x ... x d_n x 2 shape
      coords = 2 * coords - 1
      coords = coords @ self.positional_encoding_gaussian_matrix
      coords = 2 * pi * coords
      # outputs d_1 x ... x d_n x C shape
      return concatenate([sin(coords), cos(coords)], dim=-1)
  
imports: from __future__ import annotations
  from math import pi
  from typing import Optional
  import torch
  from torch import nn
  from kornia.contrib.models.common import LayerNorm2d
  from kornia.core import Device, Module, Tensor, concatenate, cos, sin, stack, zeros
label_desc: Use image node_id 2 for calling the PositionEmbeddingRandom obj's underlying member method code with example usage: obj._pe_encoding(coords) and returns: concatenate