class_docstr: Test loss functions.
class_docstr_tok: ["Test","loss","functions","."]
code: def test_graph_context_pred_loss(self):
      import torch
      from deepchem.models.losses import GraphContextPredLoss
  
      torch.manual_seed(1234)
  
      mode = "cbow"
      neg_samples = 2
      substruct_rep = torch.randn(4, 8)
      overlapped_node_rep = torch.randn(8, 8)
      context_rep = torch.randn(4, 8)
      neg_context_rep = torch.randn(2 * 4, 8)
      overlapped_context_size = torch.tensor([2, 2, 2, 2])
  
      graph_context_pred_loss = (
          GraphContextPredLoss()._create_pytorch_loss(mode, neg_samples)
      )
  
      loss = graph_context_pred_loss(
          substruct_rep,
          overlapped_node_rep,
          context_rep,
          neg_context_rep,
          overlapped_context_size,
      )
  
      assert torch.allclose(
          loss, torch.tensor(4.4781, dtype=torch.float64)
      )
  
      mode = "skipgram"
      graph_context_pred_loss = (
          GraphContextPredLoss()._create_pytorch_loss(mode, neg_samples)
      )
  
      loss = graph_context_pred_loss(
          substruct_rep,
          overlapped_node_rep,
          context_rep,
          neg_context_rep,
          overlapped_context_size,
      )
  
      assert torch.allclose(
          loss, torch.tensor(2.8531, dtype=torch.float64)
      )
  
imports: import unittest
  import numpy
  import pytest
  import deepchem
  import deepchem.models.losses
label_desc: Use image node_id 36 for calling the TestLosses obj's underlying member method code with example usage: obj.test_graph_context_pred_loss() without return types