def METHOD_NAME(model_1: torch.nn.Module, model_2: torch.nn.Module, is_equal: bool = True):
    """Check if two models are the same.
    To check equivalence, we first verify the modules are the same in each model by checking the
    list of attributes for each module. This checks if the same set of modules are used and if any
    module has been marked by adding an attribute. Next, we directly iterate over the state dict
    and verify the parameters are equal.
    This is not a comprehensive comparison. For example, an algorithm could silently monkeypatch
    over a forward function for a module. However, it is sufficient to provide coverage for our
    existing set of algorithms.
    """
    with contextlib.nullcontext() if is_equal else pytest.raises(Exception):
        # Compare model module attributes since algorithms like StochasticDepth monkeypatch
        # on new attributes. We only check this on ComposerClassifier models that have .module
        if isinstance(model_1, ComposerClassifier) and isinstance(model_2, ComposerClassifier):
            model_1_modules = list(model_1.module.modules())
            model_2_modules = list(model_2.module.modules())
            assert len(model_1_modules) == len(model_2_modules)
            for module_1, module_2 in zip(model_1_modules, model_2_modules):
                assert sorted(module_1.__dict__.keys()) == sorted(module_2.__dict__.keys())
        # Compare model parameters
        for (name0, tensor0), (name1, tensor1) in zip(model_1.state_dict().items(), model_2.state_dict().items()):
            assert name0 == name1
            assert torch.equal(tensor0, tensor1)