code: def build_positional_embedding(
      positional_embedding_type: PostionalEmbedType,
      combine_pos_embed: PostionalEmbedCombine,
      max_target_positions: int,
      input_embed_dim: int,
      embed_dim: int,
      padding_idx: int,
      no_token_positional_embeddings: bool,
  ):
      if combine_pos_embed == PostionalEmbedCombine.SUM:
          pos_embed_dim = embed_dim
      elif combine_pos_embed == PostionalEmbedCombine.CONCAT:
          pos_embed_dim = embed_dim - input_embed_dim
      else:
          raise NotImplementedError
      if not no_token_positional_embeddings:
          if positional_embedding_type == PostionalEmbedType.LEARNED:
              return PositionalEmbedding(
                  max_target_positions,
                  pos_embed_dim,
                  padding_idx,
              )
          elif (
              positional_embedding_type == PostionalEmbedType.SINUSOIDAL
              or positional_embedding_type == PostionalEmbedType.HYBRID
          ):
              return SinusoidalPositionalEmbedding(
                  pos_embed_dim,
                  padding_idx,
                  init_size=max_target_positions,
                  learned_embed=positional_embedding_type
                  == PostionalEmbedType.HYBRID,
              )
          else:
              raise NotImplementedError(
                  "Positional embedding type not supported"
              )
      else:
          return PlaceholderIdentity()
  
imports: import math
  from enum import Enum
  from typing import Dict, Optional
  import torch
  import torch.nn
  import torch.nn.functional
  from pytext.models.representations.transformer import PositionalEmbedding
  from pytext.models.seq_models.base import PlaceholderIdentity
  from torch import Tensor
  from .utils import make_positions
label_desc: Use image node_id 2 for calling a global function with example usage: build_positional_embedding(positional_embedding_type, combine_pos_embed, max_target_positions, input_embed_dim, embed_dim, padding_idx, no_token_positional_embeddings) and returns: PlaceholderIdentity, PositionalEmbedding, SinusoidalPositionalEmbedding