code: def test_freeze_layerchoice_nested():
      import torch.nn as nn
  
      class Net(ModelSpace):
          def __init__(self):
              super().__init__()
              self.module = LayerChoice(
                  [
                      LayerChoice(
                          [
                              nn.Conv2d(3, 3, kernel_size=1),
                              nn.Conv2d(3, 4, kernel_size=1),
                              nn.Conv2d(3, 5, kernel_size=1),
                          ],
                          label="b",
                      ),
                      nn.Conv2d(3, 1, kernel_size=1),
                  ],
                  label="a",
              )
  
          def forward(self, x):
              return self.module(x)
  
      orig_model = Net()
      input = torch.randn(1, 3, 5, 5)
  
      a = getattr(getattr(orig_model.module, "0"), "0")(input)
      b = orig_model.freeze({"a": 0, "b": 0})(input)
      assert torch.allclose(a, b)
  
      a = getattr(getattr(orig_model.module, "0"), "1")(input)
      b = orig_model.freeze({"a": 0, "b": 1})(input)
      assert torch.allclose(a, b)
  
      a = getattr(orig_model.module, "1")(input)
      b = orig_model.freeze({"a": 1})(input)
      assert torch.allclose(a, b)
  
      with pytest.raises(SampleValidationError):
          orig_model.freeze({"a": 0, "b": 3})
      orig_model.freeze({"a": 1, "b": 3})
  
      assert isinstance(
          orig_model.freeze({"a": 0, "b": 1}).module, nn.Conv2d
      )
      assert isinstance(
          orig_model.freeze({"a": 1, "b": 0}).module, nn.Conv2d
      )
  
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 27 for calling a global function with example usage: test_freeze_layerchoice_nested() and returns: self