class_docstr: A dataset for link prediction evaluation.
class_docstr_tok: ["A","dataset","for","link","prediction","evaluation","."]
docstr: Create a PyTorch dataset for link prediction evaluation.
  
  :param mapped_triples: shape: (n, 3)
      the ID-based triples
  :param factory:
      the triples factory. Only used of `mapped_triples` is None
  :param targets:
      the prediction targets. Defaults to head and tail prediction
  :param filtered:
      whether to use filtered evaluation, i.e., prepare filter indices
  :param additional_filter_triples:
      additional filter triples to use for creating the filter
code: def __init__(
      self,
      *,
      mapped_triples: Optional[MappedTriples] = None,
      factory: Optional[CoreTriplesFactory] = None,
      targets: Optional[Collection[Target]] = None,
      filtered: bool = True,
      additional_filter_triples: AdditionalFilterTriplesHint = None,
  ) -> None:
      """
      Create a PyTorch dataset for link prediction evaluation.
  
      :param mapped_triples: shape: (n, 3)
          the ID-based triples
      :param factory:
          the triples factory. Only used of `mapped_triples` is None
      :param targets:
          the prediction targets. Defaults to head and tail prediction
      :param filtered:
          whether to use filtered evaluation, i.e., prepare filter indices
      :param additional_filter_triples:
          additional filter triples to use for creating the filter
      """
      super().__init__()
  
      # input normalization
      if targets is None:
          targets = [LABEL_HEAD, LABEL_TAIL]
      mapped_triples = get_mapped_triples(
          mapped_triples=mapped_triples, factory=factory
      )
  
      self.mapped_triples = mapped_triples
      self.num_triples = mapped_triples.shape[0]
      self.targets = tuple(targets)
  
      # prepare filter indices if required
      if filtered:
          if not additional_filter_triples:
              logger.warning(
                  "Enabled filtered evaluation, but not additional filter triples are passed."
              )
          df = pandas.DataFrame(
              data=torch.cat(
                  [
                      mapped_triples,
                      *(
                          get_mapped_triples(x)
                          for x in upgrade_to_sequence(
                              additional_filter_triples or []
                          )
                      ),
                  ]
              ),
              columns=COLUMN_LABELS,
          )
          self.filter_indices = {
              target: FilterIndex.from_df(df=df, target=target)
              for target in targets
          }
      else:
          if additional_filter_triples:
              logger.warning(
                  "Passed additional filter triples, but filtered evaluation is disabled."
              )
          self.filter_indices = None
  
imports: import dataclasses
  import logging
  from abc import abstractmethod
  from collections import defaultdict
  from typing import Any, Collection, DefaultDict, Generic, Iterable, List, Mapping, Optional, Tuple, TypeVar, Union, cast
  import numpy
  import pandas
  import torch
  from class_resolver import HintOrType, OptionalKwargs
  from torch.utils.data import Dataset
  from torch.utils.data.dataloader import DataLoader
  from torch_max_mem import maximize_memory_utilization
  from tqdm.auto import tqdm
  from typing_extensions import TypeAlias
  from .evaluator import Evaluator, MetricResults, filter_scores_
  from ..constants import COLUMN_LABELS, TARGET_TO_INDEX
  from ..models import Model
  from ..triples import CoreTriplesFactory, get_mapped_triples
  from ..typing import LABEL_HEAD, LABEL_TAIL, InductiveMode, MappedTriples, OneOrSequence, Target
  from ..utils import upgrade_to_sequence
label_desc: Use image node_id 1 to create a new LCWAEvaluationDataset object from inherited base classes: Dataset with example: obj = LCWAEvaluationDataset()