code: def positional_encoding(position, d_model_size, dtype):
      # create the sinusoidal pattern for the positional encoding
      angle_rads = angle_defn(
          torch.arange(position, dtype=dtype).unsqueeze(1),
          torch.arange(d_model_size, dtype=dtype).unsqueeze(0),
          d_model_size,
      )
  
      sines = torch.sin(angle_rads[:, 0::2])
      cosines = torch.cos(angle_rads[:, 1::2])
  
      pos_encoding = torch.cat([sines, cosines], dim=-1)
      return pos_encoding
  
imports: from typing import Optional, Tuple, Union
  import numpy
  import torch
  from torch import nn
  from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
  from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutput
  from ...modeling_utils import PreTrainedModel
  from ...pytorch_utils import Conv1D, find_pruneable_heads_and_indices, prune_linear_layer
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_ctrl import CTRLConfig
label_desc: Use image node_id 2 for calling a global function with example usage: positional_encoding(position, d_model_size, dtype) and returns: pos_encoding