class_docstr: Unit tests for the pennylane.qnn.torch.TorchLayer class.
class_docstr_tok: ["Unit","tests","for","the","pennylane.qnn.torch.TorchLayer","class","."]
docstr: Test that a KeyError is raised when using an init_method with missing weights.
docstr_tok: ["Test","that","a","KeyError","is","raised","when","using","an","init_method","with","missing","weights","."]
code: def test_init_missing_weights(
      self, get_circuit, n_qubits
  ):  # pylint: disable=no-self-use
      """Test that a KeyError is raised when using an init_method with missing weights."""
      c, w = get_circuit
  
      init_method = {
          "w1": torch.normal(mean=0, std=1, size=(3, n_qubits, 3)),
          "w2": torch.normal(mean=0, std=1, size=(1,)),
          "w3": torch.normal(mean=0, std=1, size=[]),
          "w5": torch.normal(mean=0, std=1, size=(2, n_qubits, 3)),
          "w7": torch.normal(mean=0, std=1, size=[]),
      }
  
      with pytest.raises(KeyError):
          TorchLayer(qnode=c, weight_shapes=w, init_method=init_method)
  
imports: from unittest import mock
  import math
  from collections import defaultdict
  import numpy
  import pytest
  import pennylane
  from pennylane.qnn.torch import TorchLayer
label_desc: Use image node_id 11 for calling the TestTorchLayer obj's underlying member method code with example usage: obj.test_init_missing_weights(get_circuit, n_qubits) without return types