code: def _lm_serialize(data: List[Dict], cfg):
      logger.info("use bert tokenizer...")
      tokenizer = BertTokenizer.from_pretrained(cfg.lm_file)
      for d in data:
          sent = d["sentence"].strip()
          sent = sent.replace(d["head"], d["head_type"], 1).replace(
              d["tail"], d["tail_type"], 1
          )
          sent += "[SEP]" + d["head"] + "[SEP]" + d["tail"]
          d["token2idx"] = tokenizer.encode(
              sent, add_special_tokens=True
          )
          d["seq_len"] = len(d["token2idx"])
  
file_path: DeepKE/example/triple/cnschema/preprocess.py
imports: import os
  import logging
  from collections import OrderedDict
  from typing import List, Dict
  from transformers import BertTokenizer
  import sys
label_desc: Use image node_id 1 for calling a global function with example usage: _lm_serialize(data, cfg) without return types