code: def test_consolidate_missing_params():
      """This tests that fairseq experts, which are saved independently from the rest of the model, can be consolidated."""
      desired_path = "decoder.layers.1.moe_layer.experts.0"
      shard_metadata = {
          "param_metadata": [
              {
                  "fsdp_path": "",
                  "params": {
                      "flat_param_0": {
                          "names": ["missing"],
                          "shapes": [(12, 4)],
                          "numels": [12 * 4],
                          "padding": 0,
                      }
                  },
                  "no_broadcast_optim_state": False,
                  "shared_param_info": [],
              },
              {
                  "fsdp_path": desired_path,
                  "params": {
                      "flat_param_0": {
                          "names": [
                              "fc1.weight",
                              "fc1.bias",
                              "fc2.weight",
                              "fc2.bias",
                          ],
                          "shapes": [(4, 4), (4,), (4, 4), (4,)],
                          "numels": [16, 4, 16, 4],
                          "padding": 0,
                      }
                  },
                  "no_broadcast_optim_state": True,
                  "shared_param_info": [],
              },
          ],
          "buffer_names": ["missing.buffer"],
      }
      shard_weights = {
          "decoder.layers.1.moe_layer.experts.0.flat_param_0": torch.randn(
              40, dtype=torch.float16
          )
      }
      consolidated_weights = (
          FullyShardedDataParallel.consolidate_shard_weights(
              [shard_weights], [shard_metadata], strict=False
          )
      )
      assert len(consolidated_weights) == 4
      for k in consolidated_weights:
          assert k.startswith(
              desired_path
          ), f"{k} doesnt start with {desired_path}"
  
imports: import functools
  import os
  import tempfile
  from parameterized import parameterized
  import pytest
  import torch
  import torch.distributed
  import torch.multiprocessing
  import torch.nn
  from torch.optim import Adam
  from fairscale.fair_dev.testing.testing import in_temporary_directory, skip_if_single_gpu, temp_files_ctx
  from fairscale.nn import FullyShardedDataParallel
  from tests.nn.data_parallel.test_fsdp import DistributedTest, MixtureOfExperts, rename_test, spawn_and_init
label_desc: Use image node_id 5 for calling a global function with example usage: test_consolidate_missing_params() without return types