code: def _test_count_dataframe(
      dataset: Dataset,
      df: pandas.DataFrame,
      labels: bool = True,
      merge_subsets: bool = True,
      merge_sides: bool = True,
  ):
      """Check the general structure of a count dataframe."""
      # check correct output type
      assert isinstance(df, pandas.DataFrame)
  
      expected_columns = {triple_analysis.COUNT_COLUMN_NAME}
      expected_columns.update(
          _check_labels(
              df=df,
              labels=labels,
              id_column_name=triple_analysis.ENTITY_ID_COLUMN_NAME,
              label_column_name=triple_analysis.ENTITY_LABEL_COLUMN_NAME,
              label_to_id=dataset.entity_to_id,
          )
      )
      expected_columns.update(
          _check_labels(
              df=df,
              labels=labels,
              id_column_name=triple_analysis.RELATION_ID_COLUMN_NAME,
              label_column_name=triple_analysis.RELATION_LABEL_COLUMN_NAME,
              label_to_id=dataset.relation_to_id,
          )
      )
  
      if not merge_subsets:
          expected_columns.add(dataset_analysis.SUBSET_COLUMN_NAME)
  
          # check value range subset
          assert (
              df[dataset_analysis.SUBSET_COLUMN_NAME]
              .isin(dataset.factory_dict.keys())
              .all()
          )
  
      if not merge_sides:
          expected_columns.add(
              triple_analysis.ENTITY_POSITION_COLUMN_NAME
          )
  
          # check value range side
          assert (
              df[triple_analysis.ENTITY_POSITION_COLUMN_NAME]
              .isin(
                  {
                      LABEL_HEAD,
                      LABEL_TAIL,
                  }
              )
              .all()
          )
  
      # check columns
      assert expected_columns == set(df.columns)
  
      # check value range and type
      assert (df[triple_analysis.COUNT_COLUMN_NAME] >= 0).all()
      assert df[triple_analysis.COUNT_COLUMN_NAME].dtype == np.int64
  
imports: import itertools
  import unittest
  from typing import Iterable, Mapping
  import numpy
  import pandas
  from pykeen.datasets import Dataset, Nations
  from pykeen.datasets import analysis
  from pykeen.triples import analysis
  from pykeen.typing import LABEL_HEAD, LABEL_TAIL
label_desc: Use image node_id 2 for calling a global function with example usage: _test_count_dataframe(dataset, df, labels, merge_subsets, merge_sides) without return types