class_docstr: **Star-Transformer** 的 encoder 部分。输入 3d 的文本输入，返回相同长度的文本编码。
  基于论文 `Star-Transformer <https://arxiv.org/abs/1902.09113>`_
  
  :param hidden_size: 输入维度的大小，同时也是输出维度的大小。
  :param num_layers: **Star-Transformer** 的层数
  :param num_head: **多头注意力** head 的数目，需要能被 ``d_model`` 整除
  :param head_dim: 每个 ``head`` 的维度大小。
  :param dropout: dropout 概率
  :param max_len: 如果为 :class:`int` 表示输入序列的最大长度，模型会为输入序列加上 ``position embedding``；
      若为 ``None`` 则会跳过此步骤。
code: def __init__(
      self,
      hidden_size: int,
      num_layers: int,
      num_head: int,
      head_dim: int,
      dropout: float = 0.1,
      max_len: int = None,
  ):
      super(StarTransformer, self).__init__()
      self.iters = num_layers
  
      self.norm = nn.ModuleList(
          [
              nn.LayerNorm(hidden_size, eps=1e-6)
              for _ in range(self.iters)
          ]
      )
      # self.emb_fc = nn.Conv2d(hidden_size, hidden_size, 1)
      self.emb_drop = nn.Dropout(dropout)
      self.ring_att = nn.ModuleList(
          [
              _MSA1(
                  hidden_size,
                  nhead=num_head,
                  head_dim=head_dim,
                  dropout=0.0,
              )
              for _ in range(self.iters)
          ]
      )
      self.star_att = nn.ModuleList(
          [
              _MSA2(
                  hidden_size,
                  nhead=num_head,
                  head_dim=head_dim,
                  dropout=0.0,
              )
              for _ in range(self.iters)
          ]
      )
  
      if max_len is not None:
          self.pos_emb = nn.Embedding(max_len, hidden_size)
      else:
          self.pos_emb = None
  
file_path: fastNLP/fastNLP/modules/torch/encoder/star_transformer.py
imports: import numpy
  import torch
  from torch import nn
  from torch.nn import functional
label_desc: Use image node_id 1 to create a new StarTransformer object from inherited base classes: nn with example: obj = StarTransformer(hidden_size, num_layers, num_head, head_dim, dropout, max_len)