code: def test_categorical_multiple():
      a = CategoricalMultiple([2, 3, 5], n_chosen=None, label="a")
      assert a.simplify() == {"a": a}
      a.freeze({"a": [2, 3]}) == [2, 3]
  
      def breakdown_dm(x):
          return isinstance(x, LabeledMutable) and not isinstance(
              x, CategoricalMultiple
          )
  
      s = a.simplify(is_leaf=breakdown_dm)
      assert len(s) == 3
      assert s["a/0"].values == [True, False]
      with pytest.raises(
          SampleValidationError, match=r"a/2 is missing"
      ):
          a.freeze({"a/0": False, "a/1": True})
      assert a.freeze({"a/0": False, "a/1": True, "a/2": True}) == [
          3,
          5,
      ]
  
      a = CategoricalMultiple([2, 3, 5], n_chosen=2, label="a")
      assert a.simplify() == {"a": a}
      assert len(a.random()) == 2 and a.random() in [
          [2, 3],
          [2, 5],
          [3, 5],
      ]
      a.freeze({"a": [2, 3]}) == [2, 3]
      with pytest.raises(
          SampleValidationError, match=r"must have length 2"
      ):
          a.freeze({"a": [2, 3, 5]})
  
      s = a.simplify(is_leaf=breakdown_dm)
      assert len(s) == 4
      assert isinstance(s["a/n"], ExpressionConstraint)
      a.freeze({"a/0": True, "a/1": False, "a/2": True}) == [2, 5]
      with pytest.raises(
          SampleValidationError, match="is not satisfied"
      ):
          a.freeze({"a/0": False, "a/1": False, "a/2": True})
  
      a = CategoricalMultiple([1, 2, 3], weights=[0.2, 0.1, 0.7])
      assert list(a.grid()) == [
          [],
          [1],
          [2],
          [3],
          [1, 2],
          [1, 3],
          [2, 3],
          [1, 2, 3],
      ]
  
      counter = Counter()
      for _ in range(1000):
          for x in a.random():
              counter[x] += 1
      assert 120 <= counter[1] <= 280
      assert 50 <= counter[2] <= 150
      assert 500 <= counter[3] <= 900
  
      a = CategoricalMultiple(
          [1, 2, 3], n_chosen=2, weights=[0.3, 0.1, 0.6]
      )
      counter = Counter()
      for _ in range(1000):
          for x in a.random():
              counter[x] += 1
      assert counter[2] <= counter[1] <= counter[3]
  
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 4 for calling a global function with example usage: test_categorical_multiple() and returns: unknown