code: def load_codex(
      check_md5hash=False,
      clean_unseen=True,
      add_reciprocal_rels=False,
      return_mapper=False,
  ):
      """Load the CoDEx-M dataset.
  
      The dataset is described in :cite:`safavi_codex_2020`.
  
      .. note::
          CODEX-M contains also ground truths negative triples for test and validation sets. For more information, see
          the above reference to the original paper.
  
      The CodDEx dataset is loaded from file if it exists at the ``AMPLIGRAPH_DATA_HOME`` location.
      If ``AMPLIGRAPH_DATA_HOME`` is not set, the default  ``~/ampligraph_datasets`` is checked.
      If the dataset is not found at either location, it is downloaded and placed in ``AMPLIGRAPH_DATA_HOME``
      or ``~/ampligraph_datasets``.
  
      This dataset is divided in three splits:
  
      - `train`: 185,584 triples
      - `valid`: 10,310 triples
      - `test`: 10,310 triples
  
      Both the validation and test splits are associated with labels (binary ndarrays),
      with `True` for positive statements and `False` for  negatives:
  
      - `valid_labels`
      - `test_labels`
  
      ========= ========= ======= ================ ======= =============== ============ ===========
      Dataset   Train      Valid  Valid-negatives  Test    Test-negatives  Entities     Relations
      ========= ========= ======= ================ ======= =============== ============ ===========
      CoDEx-M   185,584   10,310  10,310           10311   10311           17,050       51
      ========= ========= ======= ================ ======= =============== ============ ===========
  
  
      Parameters
      ----------
      clean_unseen: bool
          If `True`, filters triples in validation and test sets that include entities not present in the training set.
  
      check_md5hash: bool
          If `True`, check the `md5hash` of the datset files (default: `False`).
  
      add_reciprocal_rels: bool
          Flag which specifies whether to add reciprocal relations. For every <s, p, o> in the dataset
          this creates a corresponding triple with reciprocal relation <o, p_reciprocal, s> (default: `False`).
      return_mapper: bool
          Whether to return human-readable labels in a form of dictionary in ``X["mapper"]`` field (default: `False`).
  
      Returns
      -------
  
      splits: dict
          The dataset splits: `{'train': train, 'valid': valid, 'valid_negatives': valid_negatives', 'test': test, 'test_negatives': test_negatives}`.
          Each split is a ndarray of shape (n, 3).
  
      Example
      -------
  
      >>> from ampligraph.datasets import load_codex
      >>> X = load_codex()
      >>> X["valid"][0]
      array(['Q60684', 'P106', 'Q4964182'], dtype=object)
      >>> X = load_codex(return_mapper=True)
      >>> [X['mapper'][elem]['label'] for elem in X['valid'][0]]
      ['Novalis', 'occupation', 'philosopher']
  
      """
  
      codex = DatasetMetadata(
          dataset_name="codex",
          filename="codex.zip",
          url="https://s3-eu-west-1.amazonaws.com/ampligraph/datasets/codex.zip",
          train_name="train.txt",
          valid_name="valid.txt",
          test_name="test.txt",
          valid_negatives_name="valid_negatives.txt",
          test_negatives_name="test_negatives.txt",
          mapper_name="mapper.json" if return_mapper else None,
          train_checksum="d507616dd7b9f6ddbacf83766efaa1dd",
          valid_checksum="0fd5e85f41e0ba3ef6c10093cbe2a435",
          test_checksum="7186374c5ca7075d268ccf316927041d",
          mapper_checksum="9cf7209df69562dff36ae94f95f67e82"
          if return_mapper
          else None,
          test_negatives_checksum="2dc6755e9cc54145e782480c5bb2ef44",
          valid_negatives_checksum="381300fbd297df9db2fd05bb6cfc1f2d",
      )
  
      if clean_unseen:
          return _clean_data(
              _load_dataset(
                  codex,
                  data_home=None,
                  check_md5hash=check_md5hash,
                  add_reciprocal_rels=add_reciprocal_rels,
              )
          )
      else:
          return _load_dataset(
              codex,
              data_home=None,
              check_md5hash=check_md5hash,
              add_reciprocal_rels=add_reciprocal_rels,
          )
  
imports: import hashlib
  import json
  import logging
  import os
  import urllib
  import zipfile
  from collections import namedtuple
  from pathlib import Path
  import numpy
  import pandas
label_desc: Use image node_id 27 for calling a global function with example usage: load_codex(check_md5hash, clean_unseen, add_reciprocal_rels, return_mapper) and returns: _clean_data, _load_dataset