class_docstr: An abstract evaluator for KGE models.
  
  The evaluator encapsulates the computation of evaluation metrics based on head and tail scores. To this end, it
  offers two methods to process a batch of triples together with the scores produced by some model. It maintains
  intermediate results in its state, and offers a method to obtain the final results once finished.
class_docstr_tok: ["An","abstract","evaluator","for","KGE","models",".","The","evaluator","encapsulates","the","computation","of","evaluation","metrics","based","on","head","and","tail","scores",".","To","this","end",",","it","offers","two","methods","to","process","a","batch","of","triples","together","with","the","scores","produced","by","some","model",".","It","maintains","intermediate","results","in","its","state",",","and","offers","a","method","to","obtain","the","final","results","once","finished","."]
docstr: Initialize the evaluator.
  
  :param filtered: Should filtered evaluation be performed?
  :param requires_positive_mask: Does the evaluator need access to the masks?
  :param batch_size: >0. Evaluation batch size.
  :param slice_size: >0. The divisor for the scoring function when using slicing
  :param automatic_memory_optimization: Whether to automatically optimize the sub-batch size during
      evaluation with regards to the hardware at hand.
  :param mode:
      the inductive mode, or None for transductive evaluation
docstr_tok: ["Initialize","the","evaluator",".",":","param","filtered",":","Should","filtered","evaluation","be","performed","?",":","param","requires_positive_mask",":","Does","the","evaluator","need","access","to","the","masks","?",":","param","batch_size",":",">","0",".","Evaluation","batch","size",".",":","param","slice_size",":",">","0",".","The","divisor","for","the","scoring","function","when","using","slicing",":","param","automatic_memory_optimization",":","Whether","to","automatically","optimize","the","sub-batch","size","during","evaluation","with","regards","to","the","hardware","at","hand",".",":","param","mode",":","the","inductive","mode",",","or","None","for","transductive","evaluation"]
code: def __init__(
      self,
      filtered: bool = False,
      requires_positive_mask: bool = False,
      batch_size: Optional[int] = None,
      slice_size: Optional[int] = None,
      automatic_memory_optimization: bool = True,
      mode: Optional[InductiveMode] = None,
  ):
      """Initialize the evaluator.
  
      :param filtered: Should filtered evaluation be performed?
      :param requires_positive_mask: Does the evaluator need access to the masks?
      :param batch_size: >0. Evaluation batch size.
      :param slice_size: >0. The divisor for the scoring function when using slicing
      :param automatic_memory_optimization: Whether to automatically optimize the sub-batch size during
          evaluation with regards to the hardware at hand.
      :param mode:
          the inductive mode, or None for transductive evaluation
      """
      self.filtered = filtered
      self.requires_positive_mask = requires_positive_mask
      self.batch_size = batch_size
      self.slice_size = slice_size
      self.automatic_memory_optimization = automatic_memory_optimization
      self.mode = mode
  
imports: from __future__ import annotations
  import logging
  import timeit
  import warnings
  from abc import ABC, abstractmethod
  from collections import ChainMap
  from typing import Any, ClassVar, Collection, Generic, List, Mapping, NamedTuple, Optional, Tuple, Type, TypeVar, Union, cast
  import pandas
  import torch
  from torch_max_mem import maximize_memory_utilization
  from tqdm.autonotebook import tqdm
  from ..constants import COLUMN_LABELS, TARGET_TO_INDEX, TARGET_TO_KEY_LABELS
  from ..metrics.utils import Metric
  from ..models import Model
  from ..triples.triples_factory import restrict_triples
  from ..triples.utils import get_entities, get_relations
  from ..typing import LABEL_HEAD, LABEL_RELATION, LABEL_TAIL, InductiveMode, MappedTriples, Target
  from ..utils import flatten_dictionary, format_relative_comparison, normalize_string, prepare_filter_triples
label_desc: Use image node_id 1 to create a new Evaluator object from inherited base classes: ABC, Generic with example: obj = Evaluator(filtered, requires_positive_mask, batch_size, slice_size, automatic_memory_optimization, mode)