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 callable function specified in the
  init_method argument.
docstr_tok: ["Test","if","weights","are","initialized","according","to","the","callable","function","specified","in","the","init_method","argument","."]
code: def test_callable_init(
      self, get_circuit, monkeypatch
  ):  # pylint: disable=no-self-use
      """Test if weights are initialized according to the callable function specified in the
      init_method argument."""
      c, w = get_circuit
  
      normal_ = mock.MagicMock(
          return_value=torch.normal(mean=0, std=1, size=[1])
      )
      with monkeypatch.context() as m:
          m.setattr(torch.nn.init, "uniform_", normal_)
          layer = TorchLayer(
              qnode=c, weight_shapes=w, init_method=normal_
          )
      normal_.assert_called()
      for _, weight in layer.qnode_weights.items():
          data = weight.data.tolist()
          if not isinstance(data, list):
              data = [data]
          assert data == normal_().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 8 for calling the TestTorchLayer obj's underlying member method code with example usage: obj.test_callable_init(get_circuit, monkeypatch) without return types