class_docstr: Helper class to deduplicate samples.
  
  Different from the deduplication on the HPO side,
  this class simply checks if a sample has been tried before, and does nothing else.
class_docstr_tok: ["Helper","class","to","deduplicate","samples",".","Different","from","the","deduplication","on","the","HPO","side",",","this","class","simply","checks","if","a","sample","has","been","tried","before",",","and","does","nothing","else","."]
docstr: If the new sample has not been seen before, it will be added to the history and return True.
  Otherwise, return False directly.
  
  If raise_on_dup is true, a :class:`DuplicationError` will be raised instead of returning False.
docstr_tok: ["If","the","new","sample","has","not","been","seen","before",",","it","will","be","added","to","the","history","and","return","True",".","Otherwise",",","return","False","directly",".","If","raise_on_dup","is","true",",","a",":","class",":","`","DuplicationError","`","will","be","raised","instead","of","returning","False","."]
code: def dedup(self, sample: Any) -> bool:
      """
      If the new sample has not been seen before, it will be added to the history and return True.
      Otherwise, return False directly.
  
      If raise_on_dup is true, a :class:`DuplicationError` will be raised instead of returning False.
      """
      sample = _to_hashable(sample)
      if sample in self._history:
          _logger.debug("Duplicated sample found: %s", sample)
          if self._raise_on_dup:
              raise DuplicationError(sample)
          return False
      self._history.add(sample)
      return True
  
file_path: nni/nni/nas/strategy/utils.py
imports: from __future__ import annotations
  import logging
  from typing import Any, Type, TypeVar, Callable
  from nni.mutable import SampleValidationError
label_desc: Use image node_id 2 for calling the DeduplicationHelper obj's underlying member method code with example usage: obj.dedup(sample) and returns: True, False