code: def gen_r_embedding(self, r, max_positions=10000):
      r = r * max_positions
      half_dim = self.c_r // 2
      emb = math.log(max_positions) / (half_dim - 1)
      emb = (
          torch.arange(half_dim, device=r.device)
          .float()
          .mul(-emb)
          .exp()
      )
      emb = r[:, None] * emb[None, :]
      emb = torch.cat([emb.sin(), emb.cos()], dim=1)
      if self.c_r % 2 == 1:  # zero pad
          emb = nn.functional.pad(emb, (0, 1), mode="constant")
      return emb.to(dtype=r.dtype)
  
file_path: llmga/llmga/diffusers/src/diffusers/pipelines/wuerstchen/modeling_wuerstchen_prior.py
imports: import math
  import torch
  import torch.nn
  from ...configuration_utils import ConfigMixin, register_to_config
  from ...models.modeling_utils import ModelMixin
  from .modeling_wuerstchen_common import AttnBlock, ResBlock, TimestepBlock, WuerstchenLayerNorm
label_desc: Use image node_id 2 for calling the WuerstchenPrior obj's underlying member method code with example usage: obj.gen_r_embedding(r, max_positions) and returns: emb