code: def build_position_encoding(
      hidden_dim=512,
      position_embedding="sine",
      max_len=5000,
      dropout=0.0,
  ):
      n_steps = hidden_dim // 2
      if position_embedding in "sine":
          position_embedding = PositionEmbedding(
              n_steps, max_len=max_len, dropout=dropout
          )
      elif position_embedding in "learned":
          position_embedding = PositionEmbeddingLearned(n_steps)
      else:
          raise ValueError(f"not supported {position_embedding}")
  
      return position_embedding
  
file_path: towhee/towhee/models/layers/position_encoding.py
imports: import math
  import torch
  from torch import nn
  from towhee.models.coformer.utils import NestedTensor
label_desc: Use image node_id 1 for calling a global function with example usage: build_position_encoding(hidden_dim, position_embedding, max_len, dropout) and returns: position_embedding