code: def test_default():
      D = MutableDict(
          {
              "a": Categorical([1, 2, 3], label="a"),
              "b": Categorical([4, 5, 6], label="b"),
              "c": MutableList(
                  [
                      Categorical([1, 2, 3], label="a"),
                      Numerical(0, 1, label="d"),
                  ]
              ),
              "d": Numerical(0, 1, label="d"),
          }
      )
  
      assert D.default() == {"a": 1, "b": 4, "c": [1, 0.5], "d": 0.5}
      assert Categorical([1, 2, 3], default=2).default() == 2
  
      assert CategoricalMultiple([2, 4, 6], n_chosen=2).default() == [
          2,
          4,
      ]
      assert CategoricalMultiple(
          [5, 3, 7], n_chosen=None
      ).default() == [5, 3, 7]
  
      with pytest.raises(ValueError, match="not a multiple of"):
          assert (
              Numerical(0, 1, default=0.5, quantize=0.3).default()
              == 0.5
          )
  
      assert Numerical(0, 1, default=0.9, quantize=0.3).default() == 0.9
      assert Numerical(0, 1, quantize=0.3).default() == 0.6
  
      x = Categorical([1, 2, 3], label="x")
      y = Categorical([4, 5, 6], label="y")
      exp = x + y
      assert exp.default() == 5
  
      with pytest.raises(ConstraintViolation):
          assert ExpressionConstraint(exp == 6).default() == None
  
      sample = {}
      assert (
          ExpressionConstraint(exp == 6).robust_default(sample) is None
      )
      assert sample["x"] + sample["y"] == 6
      assert x.default(sample) + y.default(sample) == 6
  
      assert (
          ExpressionConstraint(exp == 6).robust_default(sample) is None
      )
      with pytest.raises(ValueError, match=r"after \d+ retries"):
          ExpressionConstraint(exp == 7).robust_default(
              sample, retries=100
          )
  
      sample = {}
      assert (
          ExpressionConstraint(exp == 7).robust_default(sample) is None
      )
      assert sample["x"] + sample["y"] == 7
  
      with pytest.raises(ValueError, match=r"after \d+ retries"):
          ExpressionConstraint(exp == 10).robust_default(retries=100)
  
      with pytest.raises(ConstraintViolation):
          lst = MutableList(
              [ExpressionConstraint(exp == 7), x, y]
          ).default()
      lst = MutableList(
          [ExpressionConstraint(exp == 7), x, y]
      ).robust_default()
      assert lst[1] + lst[2] == 7
  
      # Specified default value conflicts with random sample
      x = Categorical([1, 2, 3], label="x", default=2)
      y = Categorical([4, 5, 6], label="y", default=4)
      sample = {}
      ExpressionConstraint(exp == 7).robust_default(sample)
      with pytest.raises(
          ValueError, match=r"Default value is specified to be"
      ):
          x.default(sample)
          y.default(sample)
  
imports: import math
  from collections import Counter
  import numpy
  import pytest
  from nni.mutable import *
  from nni.mutable.mutable import _dedup_labeled_mutables, _mutable_equal
label_desc: Use image node_id 12 for calling a global function with example usage: test_default() without return types