code: def test_ensure_frozen_freeze():
      class Net(ModelSpace):
          def __init__(self):
              super().__init__()
              self.module = Categorical([1, 2, 3], label="x")
              self.add_mutable(self.module)
              self.dry_run_value = ensure_frozen(self.module)
  
          def freeze(self, sample):
              with model_context(sample):
                  return self.__class__()
  
      model = Net()
      assert model.dry_run_value == 1
      assert model.contains({"x": 1})
      assert not model.contains({})
      assert not model.contains({"x": 4})
      model1 = model.freeze({"x": 2})
      assert model1.dry_run_value == 2
      model2 = model.freeze({"x": 3})
      assert model2.dry_run_value == 3
  
imports: import copy
  import pytest
  import torch
  import nni
  from torch import nn
  from nni.common.serializer import is_traceable
  from nni.mutable import Categorical, ExpressionConstraint, ensure_frozen, frozen_context, label_scope, auto_label, SampleMissingError
  from nni.mutable.mutable import _mutable_equal
  from nni.nas.nn.pytorch import ModelSpace, MutableModule, ParametrizedModule
  from nni.nas.space import model_context
label_desc: Use image node_id 3 for calling a global function with example usage: test_ensure_frozen_freeze() and returns: self