code: def test_optimizer_fusion(
      self,
      optimizer_type_and_kwargs: Tuple[
          Type[torch.optim.Optimizer], Dict[str, Any]
      ],
      device: torch.device,
  ) -> None:
      optimizer_type, optimizer_kwargs = optimizer_type_and_kwargs
      tables = [
          EmbeddingBagConfig(
              num_embeddings=2,
              embedding_dim=4,
              name="table_0",
              feature_names=["feature_0"],
          ),
          EmbeddingBagConfig(
              num_embeddings=2,
              embedding_dim=4,
              name="table_1",
              feature_names=["feature_1"],
          ),
      ]
  
      fused_ebc = FusedEmbeddingBagCollection(
          tables=tables,
          optimizer_type=optimizer_type,
          optimizer_kwargs=optimizer_kwargs,
          device=device,
      )
  
      ebc = EmbeddingBagCollection(tables=tables, device=device)
  
      state_dict = OrderedDict(
          [
              (
                  "embedding_bags.table_0.weight",
                  torch.Tensor([[1, 1, 1, 1], [2, 2, 2, 2]]).to(device),
              ),
              (
                  "embedding_bags.table_1.weight",
                  torch.Tensor([[4, 4, 4, 4], [8, 8, 8, 8]]).to(device),
              ),
          ]
      )
      fused_ebc.load_state_dict(state_dict)
      ebc.load_state_dict(state_dict)
  
      #        0       1        2  <-- batch
      # "f1"   [] [0]    [0,1]
      # "f2"   [1]    [0,1]    []
      #  ^
      # feature
      features = KeyedJaggedTensor.from_lengths_sync(
          keys=["feature_0", "feature_1"],
          values=torch.tensor([0, 0, 1, 1, 0, 1]),
          lengths=torch.tensor([0, 1, 2, 1, 2, 0]),
      ).to(device)
  
      opt = optimizer_type(ebc.parameters(), **optimizer_kwargs)
  
      # pyre-ignore
      def run_one_training_step() -> None:
          fused_pooled_embeddings = fused_ebc(features)
          fused_vals = []
          for _name, param in fused_pooled_embeddings.to_dict().items():
              fused_vals.append(param)
          torch.cat(fused_vals, dim=1).sum().backward()
  
          opt.zero_grad()
          pooled_embeddings = ebc(features)
  
          vals = []
          for _name, param in pooled_embeddings.to_dict().items():
              vals.append(param)
          torch.cat(vals, dim=1).sum().backward()
          opt.step()
  
      run_one_training_step()
      torch.testing.assert_close(
          ebc.state_dict()["embedding_bags.table_0.weight"],
          fused_ebc.state_dict()["embedding_bags.table_0.weight"],
      )
  
      run_one_training_step()
      torch.testing.assert_close(
          ebc.state_dict()["embedding_bags.table_0.weight"],
          fused_ebc.state_dict()["embedding_bags.table_0.weight"],
      )
  
      fused_optimizer = fused_ebc.fused_optimizer()
      fused_optimizer.load_state_dict(fused_optimizer.state_dict())
  
imports: import unittest
  from collections import OrderedDict
  from typing import Any, Dict, List, Optional, Tuple, Type
  import hypothesis.strategies
  import torch
  import torch.fx
  import torchrec
  from fbgemm_gpu.split_table_batched_embeddings_ops_training import EmbeddingLocation
  from hypothesis import given, settings
  from torchrec.modules.embedding_configs import EmbeddingBagConfig, EmbeddingConfig
  from torchrec.modules.embedding_modules import EmbeddingBagCollection, EmbeddingCollection
  from torchrec.modules.fused_embedding_modules import fuse_embedding_optimizer, FusedEmbeddingBagCollection, FusedEmbeddingCollection
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
label_desc: Use image node_id 9 for calling the FusedEmbeddingBagCollectionTest obj's underlying member method code with example usage: obj.test_optimizer_fusion(optimizer_type_and_kwargs, device) without return types