code: def test_add_mutable(
      space_format: Type[ExecutableModelSpace], nn: ModuleType
  ):
      class Net(ModelSpace, label_prefix="model"):
          def __init__(self):
              super().__init__()
              self.aux = self.add_mutable(Categorical([True, False]))
              self.head = ensure_frozen(self.aux)
  
          def forward(self, x):
              if self.head:
                  return torch.ones_like(x)
              else:
                  return torch.zeros_like(x)
  
          def freeze(self, sample):
              new_model = copy.deepcopy(self)
              new_model.head = self.aux.freeze(sample)
              return new_model
  
      if issubclass(space_format, GraphModelSpace):
          with pytest.raises(RuntimeError, match="Arbitrary"):
              space_format.from_model(Net())
      else:
          model = space_format.from_model(Net())
          assert len(model.simplify()) == 1
          label = list(model.simplify())[0]
          model1 = model.freeze({label: True})
          model2 = model.freeze({label: False})
          assert (model1.executable_model()(torch.randn(10)) == 1).all()
          assert (model2.executable_model()(torch.randn(10)) == 0).all()
  
imports: import copy
  import random
  from types import ModuleType
  from typing import Type
  import pytest
  import nni
  import nni.nas.nn.pytorch.layers
  import nni.nas.evaluator.pytorch.lightning
  import torch
  import torch.nn.functional
  from nni.mutable import Categorical, ensure_frozen, label_scope, SampleValidationError
  from nni.nas.evaluator import FunctionalEvaluator
  from nni.nas.space import RawFormatModelSpace, SimplifiedModelSpace, ExecutableModelSpace, GraphModelSpace, model_context
  from nni.nas.space.pytorch import PytorchGraphModelSpace
  from nni.nas.nn.pytorch import ParametrizedModule, MutableModule, ModelSpace, LayerChoice, InputChoice, Cell, ChosenInputs, MutableConv2d, MutableLinear
label_desc: Use image node_id 24 for calling a global function with example usage: test_add_mutable(space_format, nn) and returns: new_model, torch, torch