code: def __init__(
      self,
      d_embed: int,
      max_len: int,
      hierarchy: Optional[List[Tuple[int, int]]] = None,
  ):
      super(LearnablePositionalEmbedding, self).__init__()
      if hierarchy is None:
          hierarchy = [(max_len, d_embed)]
      sub_shape, d_sub_embeds = zip(*hierarchy)
      assert (
          reduce(mul, sub_shape, 1) == max_len
      ), f"decomposed shape {sub_shape} inconsistent with max length {max_len}"
      assert (
          reduce(add, d_sub_embeds, 0) == d_embed
      ), f"decomposed embed dim {d_sub_embeds} inconsistent with overall embed dim {d_embed}"
      self.d_embed = d_embed
      self.d_sub_embeds = d_sub_embeds
      self.max_len = max_len
      self.sub_shape = sub_shape
  
      self._weights = nn.ParameterList(
          [
              nn.Parameter(Tensor(size, dim))
              for size, dim in zip(self.sub_shape, self.d_sub_embeds)
          ]
      )
      self._reset_parameters()
  
file_path: gluonts/src/gluonts/nursery/daf/tslib/nn/attention/posemb.py
imports: from typing import Optional, List, Tuple
  from functools import reduce
  from operator import mul, add
  import math
  import torch
  from torch import Tensor, LongTensor
  from torch import nn
  from torch.nn import init
label_desc: Use image node_id 1 to create a new LearnablePositionalEmbedding object from inherited base classes: nn with example: obj = LearnablePositionalEmbedding(d_embed, max_len, hierarchy)