code: def test_metamultiheadattention_params(bias, add_bias_kv, kdim, vdim):
      meta_model = MetaMultiheadAttention(
          3 * 5,
          3,
          bias=bias,
          add_bias_kv=add_bias_kv,
          kdim=kdim,
          vdim=vdim,
      )
      model = nn.MultiheadAttention(
          3 * 5,
          3,
          bias=bias,
          add_bias_kv=add_bias_kv,
          kdim=kdim,
          vdim=vdim,
      )
  
      params = OrderedDict()
      if not meta_model._qkv_same_embed_dim:
          params["q_proj_weight"] = torch.randn(3 * 5, 3 * 5)
          model.q_proj_weight.data.copy_(params["q_proj_weight"])
  
          params["k_proj_weight"] = torch.randn(3 * 5, meta_model.kdim)
          model.k_proj_weight.data.copy_(params["k_proj_weight"])
  
          params["v_proj_weight"] = torch.randn(3 * 5, meta_model.vdim)
          model.v_proj_weight.data.copy_(params["v_proj_weight"])
  
      else:
          params["in_proj_weight"] = torch.randn(3 * 3 * 5, 3 * 5)
          model.in_proj_weight.data.copy_(params["in_proj_weight"])
  
      if bias:
          params["in_proj_bias"] = torch.randn(3 * 3 * 5)
          model.in_proj_bias.data.copy_(params["in_proj_bias"])
  
          params["out_proj.bias"] = torch.randn(3 * 5)
          model.out_proj.bias.data.copy_(params["out_proj.bias"])
  
      if add_bias_kv:
          params["bias_k"] = torch.randn(1, 1, 3 * 5)
          model.bias_k.data.copy_(params["bias_k"])
  
          params["bias_v"] = torch.randn(1, 1, 3 * 5)
          model.bias_v.data.copy_(params["bias_v"])
  
      params["out_proj.weight"] = torch.randn(3 * 5, 3 * 5)
      model.out_proj.weight.data.copy_(params["out_proj.weight"])
  
      query = torch.randn(13, 17, 3 * 5)
      key = torch.randn(19, 17, 3 * 5 if (kdim is None) else kdim)
      value = torch.randn(19, 17, 3 * 5 if (vdim is None) else vdim)
  
      outputs_torchmeta, weights_torchmeta = meta_model(
          query, key, value, params=params
      )
      outputs_nn, weights_nn = model(query, key, value)
  
      np.testing.assert_equal(
          outputs_torchmeta.detach().numpy(),
          outputs_nn.detach().numpy(),
      )
      np.testing.assert_equal(
          weights_torchmeta.detach().numpy(),
          weights_nn.detach().numpy(),
      )
  
file_path: pytorch-meta/torchmeta/tests/modules/test_activation.py
imports: import pytest
  import numpy
  import torch
  import torch.nn
  from collections import OrderedDict
  from torchmeta.modules import MetaModule
  from torchmeta.modules.activation import MetaMultiheadAttention
label_desc: Use image node_id 2 for calling a global function with example usage: test_metamultiheadattention_params(bias, add_bias_kv, kdim, vdim) without return types