code: def check_contains(
      self, sample: Sample
  ) -> Optional[SampleValidationError]:
      # Check num_nodes
      err = self.num_nodes.check_contains(sample)
      if err is not None:
          err.paths.append("num_nodes")
          return err
      num_nodes = self.num_nodes.freeze(sample)  # must succeed
      assert num_nodes >= 2
  
      # Check connections
      adjacency_list: List[List[int]] = []
      for i, inp in enumerate(self.inputs[: num_nodes - 1], start=1):
          err = inp.check_contains(sample)
          if err is not None:
              err.paths.append(f"input{i}")
              return err
          adjacency_list.append(inp.freeze(sample))
      if sum([len(e) for e in adjacency_list]) > self.max_num_edges:
          return ConstraintViolation(
              f"Expected at most {self.max_num_edges} edges, found: {adjacency_list}"
          )
      matrix = _NasBench101CellFixed.build_connection_matrix(
          adjacency_list, num_nodes
      )
  
      # Check operations
      operations: List[str] = ["IN"]
      for i, op in enumerate(self.operations[: num_nodes - 2], start=1):
          err = op.check_contains(sample)
          if err is not None:
              err.paths.append(f"op{i}")
              return err
          operations.append(op.freeze(sample))
      operations.append("OUT")
      if len(operations) != len(matrix):
          raise RuntimeError(
              "The number of operations does not match the number of nodes"
          )
  
      try:
          cur_matrix, cur_operations = prune(matrix, operations)
      except ConstraintViolation as err:
          err.paths.append("prune")
          return err
  
      # Maintain a clean copy of what nasbench101 cell looks like.
      # Modifies sample in-place. A bit hacky here.
      rv: Dict[str, Any] = {}
      for i in range(1, len(cur_matrix)):
          if i + 1 < len(cur_matrix):
              rv[f"op{i}"] = cur_operations[i]
          rv[f"input{i}"] = [k for k in range(i) if cur_matrix[k, i]]
      sample[self.label] = rv
  
imports: import logging
  from collections import OrderedDict
  from typing import Callable, List, Optional, Union, Dict, Tuple, Callable, Iterable, Any, cast
  import numpy
  import torch
  import torch.nn
  from nni.mutable import Constraint, Categorical, CategoricalMultiple, Constraint, ConstraintViolation, Mutable, LabeledMutable, Sample, SampleValidationError, auto_label, label_scope
  from nni.mutable.mutable import _mutable_equal
  from nni.nas.nn.pytorch import InputChoice, LayerChoice, MutableModule
label_desc: Use image node_id 4 for calling the NasBench101CellConstraint obj's underlying member method code with example usage: obj.check_contains(sample) and returns: err, ConstraintViolation, err, err, err