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 if weights are initialized according to the callables and values specified in the
  init_method argument.
docstr_tok: ["Test","if","weights","are","initialized","according","to","the","callables","and","values","specified","in","the","init_method","argument","."]
code: def test_fixed_and_callable_init(
      self, get_circuit
  ):  # pylint: disable=no-self-use
      """Test if weights are initialized according to the callables and values specified in the
      init_method argument."""
      c, w = get_circuit
  
      normal_ = mock.MagicMock(
          return_value=torch.normal(mean=0, std=1, size=[1])
      )
  
      init_method = {
          "w1": normal_,
          "w2": torch.normal(mean=0, std=1, size=(1,)),
          "w3": normal_,
          "w4": torch.normal(mean=0, std=1, size=(3,)),
          "w5": normal_,
          "w6": torch.normal(mean=0, std=1, size=(3,)),
          "w7": normal_,
      }
  
      layer = TorchLayer(
          qnode=c, weight_shapes=w, init_method=init_method
      )
      normal_.assert_called()
      for name, weight in layer.qnode_weights.items():
          data = weight.data.tolist()
          if not isinstance(data, list):
              data = [data]
          if isinstance(init_method[name], mock.MagicMock):
              assert data == init_method[name]().tolist()
          else:
              assert data == init_method[name].tolist()
  
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 12 for calling the TestTorchLayer obj's underlying member method code with example usage: obj.test_fixed_and_callable_init(get_circuit) without return types