code: def test_metaembeddingbag(mode):
      meta_model = MetaEmbeddingBag(5, 3, mode=mode)
      model = nn.EmbeddingBag(5, 3, mode=mode)
  
      assert isinstance(meta_model, MetaModule)
      assert isinstance(meta_model, nn.EmbeddingBag)
  
      # Set same weights for both models
      weight = torch.randn(5, 3)
      meta_model.weight.data.copy_(weight)
      model.weight.data.copy_(weight)
  
      inputs = torch.randint(5, size=(2, 7))
  
      outputs_torchmeta = meta_model(inputs, params=None)
      outputs_nn = model(inputs)
  
      np.testing.assert_equal(
          outputs_torchmeta.detach().numpy(),
          outputs_nn.detach().numpy(),
      )
  
file_path: pytorch-meta/torchmeta/tests/modules/test_sparse.py
imports: import pytest
  import numpy
  import torch
  import torch.nn
  from collections import OrderedDict
  from torchmeta.modules import MetaModule
  from torchmeta.modules.sparse import MetaEmbedding, MetaEmbeddingBag
label_desc: Use image node_id 3 for calling a global function with example usage: test_metaembeddingbag(mode) without return types