class_docstr: Constraints put extra requirements to make one sample valid.
  
  For example, a constraint can be used to express that a variable should be larger than another variable,
  or certain combinations of variables should be strictly avoided.
  
  :class:`Constraint` is a subclass of :class:`MutableAnnotation`, and thus can be used as a normal mutable.
  It has a special :meth:`contains` method, which is used to check whether a sample satisfies the constraint.
  A constraint is satisfied if and only if :meth:`contains` returns ``None``.
  
  In general, users should inherit from :class:`Constraint` to implement customized constraints.
  :class:`ExpressionConstraint` is a special constraint
  that can be used to express constraints in a more concise way.
  
  See Also
  --------
  ExpressionConstraint
docstr: Override this to implement customized constraint.
  It should return ``None`` if the sample satisfies the constraint.
  Otherwise return a :exc:`~nni.mutable.exception.ConstraintViolation` exception.
  
  See Also
  --------
  nni.mutable.Mutable.check_contains
docstr_tok: ["Override","this","to","implement","customized","constraint",".","It","should","return","``","None","``","if","the","sample","satisfies","the","constraint",".","Otherwise","return","a",":","exc",":","`","~nni.mutable.exception.ConstraintViolation","`","exception",".","See","Also","--","--","--","--","nni.mutable.Mutable.check_contains"]
code: def check_contains(
      self, sample: Sample
  ) -> SampleValidationError | None:
      """Override this to implement customized constraint.
      It should return ``None`` if the sample satisfies the constraint.
      Otherwise return a :exc:`~nni.mutable.exception.ConstraintViolation` exception.
  
      See Also
      --------
      nni.mutable.Mutable.check_contains
      """
      raise NotImplementedError()
  
imports: from __future__ import annotations
  import logging
  from typing import Iterable, Callable
  from numpy.random import RandomState
  from .exception import ConstraintViolation, SampleValidationError
  from .mutable import LabeledMutable, Mutable, Sample, MutableExpression
  from .utils import auto_label
label_desc: Use image node_id 2 for calling the Constraint obj's underlying member method code with example usage: obj.check_contains(sample) without return types