code: def test_weave_classification():
      "Test involking torch equivalent of Weave Module."
      featurizer = dc.feat.WeaveFeaturizer()
      X = featurizer(["C", "CC"])
      batch_size = 2
      model = WeaveModel(
          n_tasks=1,
          n_weave=2,
          fully_connected_layer_sizes=[2000, 1000],
          mode="classification",
          batch_size=batch_size,
      )
      (
          atom_feat,
          pair_feat,
          pair_split,
          atom_split,
          atom_to_pair,
      ) = model.compute_features_on_batch(X)
      torch.set_printoptions(precision=8)
      model = Weave(
          n_tasks=1,
          n_weave=2,
          fully_connected_layer_sizes=[2000, 1000],
          mode="classification",
      )
      input_data = [
          atom_feat,
          pair_feat,
          pair_split,
          atom_split,
          atom_to_pair,
      ]
  
      for i in range(2):
          model.layers[i].W_AA = torch.from_numpy(
              np.load(
                  f"deepchem/models/tests/assets/weavelayer_W_AA_{i}.npy"
              )
          )
          model.layers[i].W_PA = torch.from_numpy(
              np.load(
                  f"deepchem/models/tests/assets/weavelayer_W_PA_{i}.npy"
              )
          )
          model.layers[i].W_A = torch.from_numpy(
              np.load(
                  f"deepchem/models/tests/assets/weavelayer_W_A_{i}.npy"
              )
          )
          if model.layers[i].update_pair:
              model.layers[i].W_AP = torch.from_numpy(
                  np.load(
                      f"deepchem/models/tests/assets/weavelayer_W_AP_{i}.npy"
                  )
              )
              model.layers[i].W_PP = torch.from_numpy(
                  np.load(
                      f"deepchem/models/tests/assets/weavelayer_W_PP_{i}.npy"
                  )
              )
              model.layers[i].W_P = torch.from_numpy(
                  np.load(
                      f"deepchem/models/tests/assets/weavelayer_W_P_{i}.npy"
                  )
              )
      dense1_weights = np.load(
          "deepchem/models/tests/assets/dense1_weights.npy"
      ).astype(np.float32)
      dense1_bias = np.load(
          "deepchem/models/tests/assets/dense1_bias.npy"
      ).astype(np.float32)
      model.dense1.weight.data = torch.from_numpy(
          np.transpose(dense1_weights)
      )
      model.dense1.bias.data = torch.from_numpy(dense1_bias)
  
      layers2_0_weights = np.load(
          "deepchem/models/tests/assets/layers2_0_weights.npy"
      ).astype(np.float32)
      layers2_0_bias = np.load(
          "deepchem/models/tests/assets/layers2_0_bias.npy"
      ).astype(np.float32)
  
      model.layers2[0].weight.data = torch.from_numpy(
          np.transpose(layers2_0_weights)
      )
      model.layers2[0].bias.data = torch.from_numpy(layers2_0_bias)
  
      if model.weave_gather.compress_post_gaussian_expansion:
          model.weave_gather.W = torch.from_numpy(
              np.load("deepchem/models/tests/assets/weavegather.npy")
          )
  
      layers2_1_weights = np.load(
          "deepchem/models/tests/assets/layers2_1_weights.npy"
      ).astype(np.float32)
      layers2_1_bias = np.load(
          "deepchem/models/tests/assets/layers2_1_bias.npy"
      ).astype(np.float32)
  
      model.layers2[1].weight.data = torch.from_numpy(
          np.transpose(layers2_1_weights)
      )
      model.layers2[1].bias.data = torch.from_numpy(layers2_1_bias)
  
      layer_2_weights = np.load(
          "deepchem/models/tests/assets/layer_2_weights.npy"
      ).astype(np.float32)
      layer_2_bias = np.load(
          "deepchem/models/tests/assets/layer_2_bias.npy"
      ).astype(np.float32)
  
      model.layer_2.weight.data = torch.from_numpy(
          np.transpose(layer_2_weights)
      )
      model.layer_2.bias.data = torch.from_numpy(layer_2_bias)
  
      outputs = model(input_data)
      assert len(outputs) == 2
      assert np.allclose(
          outputs[1].detach().numpy(),
          np.load(
              "deepchem/models/tests/assets/classification_logits.npy"
          ),
          atol=1e-4,
      )
      assert np.allclose(
          outputs[0].detach().numpy(),
          np.load(
              "deepchem/models/tests/assets/classification_output.npy"
          ),
          atol=1e-4,
      )
  
file_path: deepchem/deepchem/models/tests/test_weavemodel_pytorch.py
imports: import deepchem
  import numpy
  import os
  import pytest
  import tempfile
  from flaky import flaky
  from deepchem.data import NumpyDataset
  from deepchem.metrics import Metric, roc_auc_score, mean_absolute_error
  from deepchem.molnet import load_bace_classification, load_delaney
  from deepchem.feat import WeaveFeaturizer
label_desc: Use image node_id 4 for calling a global function with example usage: test_weave_classification() without return types