class_docstr: 一个基础的 Sequence labeling 的模型。
  用于做 sequence labeling 的基础类。结构包含一层 ``Embedding`` ，一层 :class:`~fastNLP.modules.torch.encoder.LSTM` (单向，一层)，
  一层全连接层，以及一层 :class:`CRF <fastNLP.modules.torch.decoder.ConditionalRandomField>` 。
  
  :param embed: 支持以下几种输入类型：
  
          - ``tuple(num_embedings, embedding_dim)``，即 embedding 的大小和每个词的维度，此时将随机初始化一个 :class:`torch.nn.Embedding` 实例；
          - :class:`torch.nn.Embedding` 或 **fastNLP** 的 ``Embedding`` 对象，此时就以传入的对象作为 embedding；
          - :class:`numpy.ndarray` ，将使用传入的 ndarray 作为 Embedding 初始化；
          - :class:`torch.Tensor`，此时将使用传入的值作为 Embedding 初始化；
  :param hidden_size: :class:`fastNLP.modules.torch.encoder.LSTM` 隐藏层的大小
  :param num_classes: 一共有多少类
class_docstr_tok: ["\u4e00\u4e2a\u57fa\u7840\u7684","Sequence","labeling","\u7684\u6a21\u578b\u3002","\u7528\u4e8e\u505a","sequence","labeling","\u7684\u57fa\u7840\u7c7b\u3002\u7ed3\u6784\u5305\u542b\u4e00\u5c42","``","Embedding","``","\uff0c\u4e00\u5c42",":","class",":","`","~fastNLP.modules.torch.encoder.LSTM","`","(","\u5355\u5411\uff0c\u4e00\u5c42",")","\uff0c","\u4e00\u5c42\u5168\u8fde\u63a5\u5c42\uff0c\u4ee5\u53ca\u4e00\u5c42",":","class",":","`","CRF","<","fastNLP.modules.torch.decoder.ConditionalRandomField",">","`","\u3002",":","param","embed",":","\u652f\u6301\u4ee5\u4e0b\u51e0\u79cd\u8f93\u5165\u7c7b\u578b\uff1a","-","``","tuple","(","num_embedings",",","embedding_dim",")","``","\uff0c\u5373","embedding","\u7684\u5927\u5c0f\u548c\u6bcf\u4e2a\u8bcd\u7684\u7ef4\u5ea6\uff0c\u6b64\u65f6\u5c06\u968f\u673a\u521d\u59cb\u5316\u4e00\u4e2a",":","class",":","`","torch.nn.Embedding","`","\u5b9e\u4f8b\uff1b","-",":","class",":","`","torch.nn.Embedding","`","\u6216","*","*","fastNLP","*","*","\u7684","``","Embedding","``","\u5bf9\u8c61\uff0c\u6b64\u65f6\u5c31\u4ee5\u4f20\u5165\u7684\u5bf9\u8c61\u4f5c\u4e3a","embedding\uff1b","-",":","class",":","`","numpy.ndarray","`","\uff0c\u5c06\u4f7f\u7528\u4f20\u5165\u7684","ndarray","\u4f5c\u4e3a","Embedding","\u521d\u59cb\u5316\uff1b","-",":","class",":","`","torch.Tensor","`","\uff0c\u6b64\u65f6\u5c06\u4f7f\u7528\u4f20\u5165\u7684\u503c\u4f5c\u4e3a","Embedding","\u521d\u59cb\u5316\uff1b",":","param","hidden_size",":",":","class",":","`","fastNLP.modules.torch.encoder.LSTM","`","\u9690\u85cf\u5c42\u7684\u5927\u5c0f",":","param","num_classes",":","\u4e00\u5171\u6709\u591a\u5c11\u7c7b"]
docstr: :param words: 句子中 word 的 index，形状为 ``[batch_size, seq_len]``
  :param seq_len: 每个句子的长度，形状为 ``[batch,]``
  :return: 预测结果 ``{'pred': torch.Tensor}``
docstr_tok: [":","param","words",":","\u53e5\u5b50\u4e2d","word","\u7684","index\uff0c\u5f62\u72b6\u4e3a","``","[","batch_size",",","seq_len","]","``",":","param","seq_len",":","\u6bcf\u4e2a\u53e5\u5b50\u7684\u957f\u5ea6\uff0c\u5f62\u72b6\u4e3a","``","[","batch",",","]","``",":","return",":","\u9884\u6d4b\u7ed3\u679c","``","{","'pred","'",":","torch.Tensor","}","``"]
code: def forward(
      self, words: "torch.LongTensor", seq_len: "torch.LongTensor"
  ):
      r"""
      :param words: 句子中 word 的 index，形状为 ``[batch_size, seq_len]``
      :param seq_len: 每个句子的长度，形状为 ``[batch,]``
      :return: 预测结果 ``{'pred': torch.Tensor}``
      """
      x = self.embedding(words)
      # [batch_size, max_len, word_emb_dim]
      x, _ = self.rnn(x, seq_len)
      # [batch_size, max_len, hidden_size * direction]
      x = self.fc(x)
      return {"pred": x}
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from ...core.utils import seq_len_to_mask
  from ...embeddings.torch.utils import get_embeddings
  from ...modules.torch.decoder import ConditionalRandomField
  from ...modules.torch.encoder import LSTM
  from ...modules.torch import decoder, encoder
  from ...modules.torch.decoder.crf import allowed_transitions
label_desc: Use image node_id 2 for calling the SeqLabeling obj's underlying member method code with example usage: obj.forward(words, seq_len) and returns: dict