class_docstr: Implementation of knowledge graph interface in pglke.
  
  Args:
      triplets (dict):
          Triplet data of knowledge graphs with keys 'train', 'valid' and 'test'.
      num_ents (int, optional):
          Number of entities in a knowledge graph.
          If not provided, it will be inferred from triplets.
      num_rels (int, optional):
          Number of relations in a knowledge graph.
          If not provided, it will be inferred from triplets.
      ent_feat (np.ndarray, optional):
          Entity features, which have consistent order with entity ids.
      rel_feat (np.ndarray, optional):
          Relation features, which have consistent order with relation ids.
docstr: Randomly sample :code:`percent`% of original triplets inplace.
  
  Args:
      percent (float):
          The percent of triplets sampled.
      dataset (str, optional: 'train', 'valid', 'test', 'all'):
          The triplet data to be sampled.
docstr_tok: ["Randomly","sample",":","code",":","`","percent","`","%","of","original","triplets","inplace",".","Args",":","percent","(","float",")",":","The","percent","of","triplets","sampled",".","dataset","(","str",",","optional",":","'train","'",",","'valid","'",",","'test","'",",","'all","'",")",":","The","triplet","data","to","be","sampled","."]
code: def sampled_subgraph(self, percent, dataset="all"):
      """
      Randomly sample :code:`percent`% of original triplets inplace.
  
      Args:
          percent (float):
              The percent of triplets sampled.
          dataset (str, optional: 'train', 'valid', 'test', 'all'):
              The triplet data to be sampled.
      """
  
      def _sample_subgraph(data):
          if isinstance(data, dict):
              for key in data:
                  data[key] = _sample_subgraph(data[key])
          elif isinstance(data, np.ndarray):
              max_index = int(data.shape[0] * percent)
              data = data[:max_index]
          return data
  
      if dataset == "train" or dataset == "all":
          self._train = _sample_subgraph(self._train)
      if dataset == "valid" or dataset == "all":
          self._valid = _sample_subgraph(self._valid)
      if dataset == "test" or dataset == "all":
          self._test = _sample_subgraph(self._test)
  
imports: import os
  import json
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 25 for calling the TriGraph obj's underlying member method code with example usage: obj.sampled_subgraph(percent, dataset) and returns: data