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: Count the number of entities.
          
docstr_tok: ["Count","the","number","of","entities","."]
code: def maybe_num_ents(self):
      """Count the number of entities."""
      ents = []
  
      def extract_ents(data):
          """Extract entities from data."""
          if isinstance(data, dict):
              ents.append(np.unique(data["h"]))
              if data["mode"] is not "wikikg90m":
                  ents.append(np.unique(data["t"]))
              else:
                  ents.append(
                      np.unique(data["t_candidate"].reshape((-1,)))
                  )
          elif isinstance(data, np.ndarray):
              ents_data = np.concatenate([data[:, 0], data[:, 2]])
              ents.append(np.unique(ents_data))
  
      extract_ents(self._train)
      extract_ents(self._valid)
      extract_ents(self._test)
      num_ents = np.unique(np.concatenate(ents)).shape[0]
      return num_ents
  
imports: import os
  import json
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 3 for calling the TriGraph obj's underlying member method code with example usage: obj.maybe_num_ents() and returns: num_ents