docstr: Test assumption of consolidate_optimizer_state_dict
docstr_tok: ["Test","assumption","of","consolidate_optimizer_state_dict"]
code: def test_named_params_ordering(self):
      """Test assumption of consolidate_optimizer_state_dict"""
      group = DummyProcessGroup(0, 1)
      model = TransformerWithSharedParams(group)
      named_pars = [p for n, p in model.named_parameters()]
      for i, p in enumerate(model.parameters()):
          objects_are_equal(p, named_pars[i], raise_exception=True)
  
imports: import copy
  import functools
  from time import time
  import unittest
  from parameterized import parameterized
  import torch
  from torch import nn
  from torch.optim import SGD, Adadelta, Adam
  from fairscale.fair_dev.testing.testing import dist_init, objects_are_equal, spawn_for_all_world_sizes
  from fairscale.internal.params import recursive_copy_to_device
  from fairscale.nn.data_parallel import FullyShardedDataParallel, get_fsdp_instances
  from fairscale.nn.data_parallel.fsdp_optim_utils import is_singleton_tensor
  from .test_fsdp import DistributedTest, DummyProcessGroup, MixtureOfExperts, TransformerWithSharedParams, rename_test, spawn_and_init
label_desc: Use image node_id 6 for calling the TestOptimizerUtils obj's underlying member method code with example usage: obj.test_named_params_ordering() without return types