text: import jieba
  import numpy as np
  import os
  import random
  import torch
  
  
  def tokenize(string):
      res = list(jieba.cut(string, cut_all=False))
      return res
  
  
  # 把数据转换成index
  def seq2index(seq, vocab):
      seg = tokenize(seq)
      seg_index = []
      for s in seg:
          seg_index.append(vocab.get(s, 1))
      return seg_index
  
  
  # 统一长度
  def padding_seq(X, max_len=10):
      return np.array([
          np.concatenate([x, [0] * (max_len - len(x))]) if len(x) < max_len else x[:max_len] for x in X
      ])
  
  
  def fix_seed(seed=3407):
      random.seed(seed)
      os.environ['PYTHONHASHSEED'] = str(seed)
      np.random.seed(seed)
      torch.manual_seed(seed)
      torch.cuda.manual_seed(seed)
      torch.backends.cudnn.deterministic = True
  