class_docstr: :class:`KnowledgeBasedDataset` is based on :class:`~recbole.data.dataset.dataset.Dataset`,
  and load ``.kg`` and ``.link`` additionally.
  
  Entities are remapped together with ``item_id`` specially.
  All entities are remapped into three consecutive ID sections.
  
  - virtual entities that only exist in interaction data.
  - entities that exist both in interaction data and kg triplets.
  - entities only exist in kg triplets.
  
  It also provides several interfaces to transfer ``.kg`` features into coo sparse matrix,
  csr sparse matrix, :class:`DGL.Graph` or :class:`PyG.Data`.
  
  Attributes:
      head_entity_field (str): The same as ``config['HEAD_ENTITY_ID_FIELD']``.
  
      tail_entity_field (str): The same as ``config['TAIL_ENTITY_ID_FIELD']``.
  
      relation_field (str): The same as ``config['RELATION_ID_FIELD']``.
  
      entity_field (str): The same as ``config['ENTITY_ID_FIELD']``.
  
      kg_feat (pandas.DataFrame): Internal data structure stores the kg triplets.
          It's loaded from file ``.kg``.
  
      item2entity (dict): Dict maps ``item_id`` to ``entity``,
          which is loaded from  file ``.link``.
  
      entity2item (dict): Dict maps ``entity`` to ``item_id``,
          which is loaded from  file ``.link``.
  
  Note:
      :attr:`entity_field` doesn't exist exactly. It's only a symbol,
      representing entity features.
  
      ``[UI-Relation]`` is a special relation token.
code: def _create_ckg_sparse_matrix(self, form="coo", show_relation=False):
      user_num = self.user_num
  
      hids = self.head_entities + user_num
      tids = self.tail_entities + user_num
  
      uids = self.inter_feat[self.uid_field].numpy()
      iids = self.inter_feat[self.iid_field].numpy() + user_num
  
      ui_rel_num = len(uids)
      ui_rel_id = self.relation_num - 1
      assert (
          self.field2id_token[self.relation_field][ui_rel_id]
          == "[UI-Relation]"
      )
  
      src = np.concatenate([uids, iids, hids])
      tgt = np.concatenate([iids, uids, tids])
  
      if not show_relation:
          data = np.ones(len(src))
      else:
          kg_rel = self.kg_feat[self.relation_field].numpy()
          ui_rel = np.full(
              2 * ui_rel_num, ui_rel_id, dtype=kg_rel.dtype
          )
          data = np.concatenate([ui_rel, kg_rel])
      node_num = self.entity_num + self.user_num
      mat = coo_matrix((data, (src, tgt)), shape=(node_num, node_num))
      if form == "coo":
          return mat
      elif form == "csr":
          return mat.tocsr()
      else:
          raise NotImplementedError(
              f"Sparse matrix format [{form}] has not been implemented."
          )
  
imports: import os
  from collections import Counter
  import numpy
  import pandas
  import torch
  from scipy.sparse import coo_matrix
  from recbole.data.dataset import Dataset
  from recbole.utils import FeatureSource, FeatureType, set_color
  from recbole.utils.url import decide_download, download_url, extract_zip
label_desc: Use image node_id 28 for calling the KnowledgeBasedDataset obj's underlying member method code with example usage: obj._create_ckg_sparse_matrix(form, show_relation) and returns: mat, mat