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_graph(self, form="dgl", show_relation=False):
      user_num = self.user_num
  
      kg_tensor = self.kg_feat
      inter_tensor = self.inter_feat
  
      head_entity = kg_tensor[self.head_entity_field] + user_num
      tail_entity = kg_tensor[self.tail_entity_field] + user_num
  
      user = inter_tensor[self.uid_field]
      item = inter_tensor[self.iid_field] + user_num
  
      src = torch.cat([user, item, head_entity])
      tgt = torch.cat([item, user, tail_entity])
  
      if show_relation:
          ui_rel_num = user.shape[0]
          ui_rel_id = self.relation_num - 1
          assert (
              self.field2id_token[self.relation_field][ui_rel_id]
              == "[UI-Relation]"
          )
          kg_rel = kg_tensor[self.relation_field]
          ui_rel = torch.full(
              (2 * ui_rel_num,), ui_rel_id, dtype=kg_rel.dtype
          )
          edge = torch.cat([ui_rel, kg_rel])
  
      if form == "dgl":
          import dgl
  
          graph = dgl.graph((src, tgt))
          if show_relation:
              graph.edata[self.relation_field] = edge
          return graph
      elif form == "pyg":
          from torch_geometric.data import Data
  
          edge_attr = edge if show_relation else None
          graph = Data(
              edge_index=torch.stack([src, tgt]), edge_attr=edge_attr
          )
          return graph
      else:
          raise NotImplementedError(
              f"Graph 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 29 for calling the KnowledgeBasedDataset obj's underlying member method code with example usage: obj._create_ckg_graph(form, show_relation) and returns: graph, graph