code: def build_rotary_pos_embed(
      feat_shape: List[int],
      bands: Optional[torch.Tensor] = None,
      dim: int = 64,
      max_res: int = 224,
      temperature: float = 10000.0,
      linear_bands: bool = False,
      in_pixels: bool = True,
      ref_feat_shape: Optional[List[int]] = None,
      dtype: torch.dtype = torch.float32,
      device: Optional[torch.device] = None,
  ):
      """
  
      Args:
          feat_shape: Spatial shape of the target tensor for embedding.
          bands: Optional pre-generated frequency bands
          dim: Output dimension of embedding tensor.
          max_res: Maximum resolution for pixel mode.
          temperature: Temperature (inv freq) for non-pixel mode
          linear_bands: Linearly (instead of log) spaced bands for pixel mode
          in_pixels: Pixel vs language (inv freq) mode.
          dtype: Output dtype.
          device: Output device.
  
      Returns:
  
      """
      sin_emb, cos_emb = build_fourier_pos_embed(
          feat_shape,
          bands=bands,
          num_bands=dim // 4,
          max_res=max_res,
          temperature=temperature,
          linear_bands=linear_bands,
          in_pixels=in_pixels,
          ref_feat_shape=ref_feat_shape,
          device=device,
          dtype=dtype,
      )
      num_spatial_dim = 1
      # this would be much nicer as a .numel() call to torch.Size(), but torchscript sucks
      for x in feat_shape:
          num_spatial_dim *= x
      sin_emb = sin_emb.reshape(num_spatial_dim, -1).repeat_interleave(
          2, -1
      )
      cos_emb = cos_emb.reshape(num_spatial_dim, -1).repeat_interleave(
          2, -1
      )
      return sin_emb, cos_emb
  
imports: import math
  from typing import List, Tuple, Optional, Union
  import torch
  from torch import nn
  from .trace_utils import _assert
label_desc: Use image node_id 10 for calling a global function with example usage: build_rotary_pos_embed(feat_shape, bands, dim, max_res, temperature, linear_bands, in_pixels, ref_feat_shape, dtype, device) and returns: sin_emb,  cos_emb