code: def get_relation_functionality_df(
      *,
      dataset: Dataset,
      parts: Optional[Collection[str]] = None,
      add_labels: bool = True,
  ) -> pd.DataFrame:
      """
      Calculate the functionality and inverse functionality score per relation.
  
      The (inverse) functionality was proposed in [wang2018]_. It is defined as the number of unique head (tail) entities
      divided by the of triples in which the relation occurs. Thus, its value range is [0, 1]. Smaller values indicate
      that entities usually have more than one outgoing (incoming) triple with the corresponding relation type. Hence,
      the score is related to the relation cardinality types.
  
      :param dataset:
          The dataset to investigate.
      :param parts:
          Only use certain parts of the dataset, e.g., train triples. Defaults to using all triples, i.e.
          {"training", "validation", "testing}.
      :param add_labels:
          Whether to add relation labels (if available).
  
      :return:
          A dataframe with columns (relation_id | functionality | inverse functionality)
  
      .. [wang2018]
          Wang, Z., *et al.* (2018). `Cross-lingual Knowledge Graph Alignment via Graph Convolutional Networks
          <https://doi.org/10.18653/v1/D18-1032>`_. Proceedings of the 2018 Conference on Empirical Methods in
          Natural Language Processing, 349–357.
      """
      # TODO: Consider merging with other analysis methods
      parts = _normalize_parts(dataset=dataset, parts=parts)
      mapped_triples = _get_mapped_triples(dataset=dataset, parts=parts)
      return triple_analysis.get_relation_functionality(
          mapped_triples,
          add_labels=add_labels,
          label_to_id=dataset.relation_to_id,
      )
  
file_path: pykeen/src/pykeen/datasets/analysis.py
imports: import logging
  from typing import Callable, Collection, Optional, Tuple, Union
  import pandas
  import torch
  from .base import Dataset
  from ..constants import PYKEEN_DATASETS
  from ..triples import analysis
  from ..typing import MappedTriples
label_desc: Use image node_id 10 for calling a global function with example usage: get_relation_functionality_df() and returns: triple_analysis