code: def test_mutable_descendants():
      class A(MutableModule):
          pass
  
      class B(MutableModule):
          def check_contains(self, sample):
              if "test" in sample:
                  return SampleMissingError("test")
  
      class C(MutableModule):
          def __init__(self):
              super().__init__()
              self.b = B()
  
      class D(nn.Module):
          def __init__(self):
              super().__init__()
              self.c = C()
  
      class E(MutableModule):
          def __init__(self):
              super().__init__()
              self.a = A()
              self.d = D()
  
      e = E()
      descendants = list(e.mutable_descendants())
      assert len(descendants) == 2
      assert [_[0] for _ in e.named_mutable_descendants()] == [
          "a",
          "d.c",
      ]
      assert isinstance(descendants[0], A)
      assert isinstance(descendants[1], C)
  
      assert (
          repr(e)
          == """E(
    (a): A()
    (d): D(
      (c): C(
        (b): B()
      )
    )
  )"""
      )
      frozen_e = e.freeze({})
      assert e is not frozen_e
      assert repr(e) == repr(frozen_e)
  
      e.validate({})
      with pytest.raises(SampleMissingError, match="d.c"):
          e.validate({"test": 1})
  
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 19 for calling a global function with example usage: test_mutable_descendants() and returns: SampleMissingError