class_docstr: Load knowledge graph data from files
  
  Args:
      path (str):
          Directory of triplet dataset.
      data_name (str):
          The folder name of triplet dataset.
      hrt_mode (str, optional):
          The order of head, relation and tail per line in triplet file.
          Choices: 'hrt', 'htr', 'trh', 'thr', 'rht', 'rth'.
      kv_mode (str, optional):
          The order of string names and ids in dictionary files.
          'kv' denotes entity_name/relation_name, id.
      train_file (str, optional):
          Filename of training data.
      valid_file (str, optional):
          Filename of validation data.
      test_file (str, optional):
          Filename of test data.
      ent_file (str, optional):
          Filename of entity_to_id dictionary.
      rel_file (str, optional):
          Filename of relation_to_id dictionary.
      delimiter (char, optional):
          The delimiter in files.
      map_to_id (bool, optional):
          Whether to map loaded elements into int ids.
      load_dict (bool, optional):
          Whether to load dictionaries from files.
      skip_head (bool, optional):
          Whether to ignore the first line of dictionary files.
class_docstr_tok: ["Load","knowledge","graph","data","from","files","Args",":","path","(","str",")",":","Directory","of","triplet","dataset",".","data_name","(","str",")",":","The","folder","name","of","triplet","dataset",".","hrt_mode","(","str",",","optional",")",":","The","order","of","head",",","relation","and","tail","per","line","in","triplet","file",".","Choices",":","'hrt","'",",","'htr","'",",","'trh","'",",","'thr","'",",","'rht","'",",","'rth","'",".","kv_mode","(","str",",","optional",")",":","The","order","of","string","names","and","ids","in","dictionary","files",".","'kv","'","denotes","entity_name\/relation_name",",","id",".","train_file","(","str",",","optional",")",":","Filename","of","training","data",".","valid_file","(","str",",","optional",")",":","Filename","of","validation","data",".","test_file","(","str",",","optional",")",":","Filename","of","test","data",".","ent_file","(","str",",","optional",")",":","Filename","of","entity_to_id","dictionary",".","rel_file","(","str",",","optional",")",":","Filename","of","relation_to_id","dictionary",".","delimiter","(","char",",","optional",")",":","The","delimiter","in","files",".","map_to_id","(","bool",",","optional",")",":","Whether","to","map","loaded","elements","into","int","ids",".","load_dict","(","bool",",","optional",")",":","Whether","to","load","dictionaries","from","files",".","skip_head","(","bool",",","optional",")",":","Whether","to","ignore","the","first","line","of","dictionary","files","."]
code: def __init__(
      self,
      path,
      data_name,
      hrt_mode="hrt",
      kv_mode="kv",
      train_file="train.txt",
      valid_file="valid.txt",
      test_file="test.txt",
      ent_file="entities.dict",
      rel_file="relations.dict",
      ent_feat_path=None,
      rel_feat_path=None,
      delimiter="\t",
      map_to_id=False,
      load_dict=False,
      skip_head=False,
  ):
      super(TripletDataset, self).__init__()
      self._path = os.path.join(path, data_name)
      hrt_dict = dict([x, i] for i, x in enumerate(hrt_mode))
      self._hrt = [hrt_dict[x] for x in ["h", "r", "t"]]
      self._kv = True if kv_mode == "kv" else False
      self._name = data_name
      self._data_list = [train_file, valid_file, test_file]
      self._feat_path = [ent_feat_path, rel_feat_path]
      self._delimiter = delimiter
      self._map_to_id = map_to_id
      self._skip_head = skip_head
      self._load_dict = load_dict
  
      if not os.path.exists(self._path):
          raise ValueError("data path %s not exists!" % self._path)
  
      ent_dict_path = os.path.join(self._path, ent_file)
      rel_dict_path = os.path.join(self._path, rel_file)
      if not self._load_dict:
          self.create_dict(ent_dict_path, rel_dict_path)
      self._ent_dict = self.load_dictionary(
          ent_dict_path, self._kv, self._delimiter, self._skip_head
      )
      self._rel_dict = self.load_dictionary(
          rel_dict_path, self._kv, self._delimiter, self._skip_head
      )
      self.num_ents = len(self._ent_dict)
      self.num_rels = len(self._rel_dict)
  
      self.ent_feat = None
      self.rel_feat = None
      self.train, self.valid, self.test = self.load_dataset()
      self.triplets = {
          "train": self.train,
          "valid": {
              "mode": "hrt",
              "h": self.valid[:, 0],
              "r": self.valid[:, 1],
              "t": self.valid[:, 2],
              "candidate": self.num_ents,
          },
          "test": {
              "mode": "hrt",
              "h": self.test[:, 0],
              "r": self.test[:, 1],
              "t": self.test[:, 2],
              "candidate": self.num_ents,
          },
      }
  
imports: import os
  import time
  import numpy
  import paddle.distributed
  from dataset.trigraph import TriGraph
  from utils import timer_wrapper
label_desc: Use image node_id 1 to create a new TripletDataset object from inherited base classes: object with example: obj = TripletDataset(path, data_name, hrt_mode, kv_mode, train_file, valid_file, test_file, ent_file, rel_file, ent_feat_path, rel_feat_path, delimiter, map_to_id, load_dict, skip_head)