code: def test_grover_pretraining_task_overfit(tmpdir):
      import deepchem as dc
      from deepchem.feat.vocabulary_builders import (
          GroverAtomVocabularyBuilder,
          GroverBondVocabularyBuilder,
      )
      from deepchem.models.torch_models.grover import GroverModel
  
      import pandas as pd
  
      df = pd.DataFrame({"smiles": ["CC"], "preds": [0]})
  
      filepath = os.path.join(tmpdir, "example.csv")
      df.to_csv(filepath, index=False)
  
      dataset_path = os.path.join(filepath)
      loader = dc.data.CSVLoader(
          tasks=["preds"],
          featurizer=dc.feat.DummyFeaturizer(),
          feature_field=["smiles"],
      )
      dataset = loader.create_dataset(dataset_path)
  
      av = GroverAtomVocabularyBuilder()
      av.build(dataset)
  
      bv = GroverBondVocabularyBuilder()
      bv.build(dataset)
  
      fg = dc.feat.CircularFingerprint()
      loader2 = dc.data.CSVLoader(
          tasks=["preds"],
          featurizer=dc.feat.GroverFeaturizer(features_generator=fg),
          feature_field="smiles",
      )
      graph_data = loader2.create_dataset(dataset_path)
  
      model = GroverModel(
          node_fdim=151,
          edge_fdim=165,
          atom_vocab=av,
          bond_vocab=bv,
          features_dim=2048,
          hidden_size=128,
          functional_group_size=85,
          task="pretraining",
          device=torch.device("cpu"),
      )
  
      # since pretraining is a self-supervision task where labels are generated during
      # preparing batch, we mock _prepare_batch_for_pretraining to set all labels to 0.
      # The test here is checking whether the model predict 0's after overfitting.
      def _prepare_batch_for_pretraining(batch):
          from deepchem.feat.graph_data import BatchGraphData
          from deepchem.utils.grover import extract_grover_attributes
  
          X, y, w = batch
          batchgraph = BatchGraphData(X[0])
          fgroup_label = getattr(batchgraph, "fg_labels")
  
          (
              f_atoms,
              f_bonds,
              a2b,
              b2a,
              b2revb,
              a2a,
              a_scope,
              b_scope,
              _,
              _,
          ) = extract_grover_attributes(batchgraph)
  
          # preparing for test by setting 0 labels
          atom_vocab_label = torch.zeros(f_atoms.shape[0]).long()
          bond_vocab_label = torch.zeros(f_bonds.shape[0] // 2).long()
          fg_task = torch.zeros(fgroup_label.shape)
          labels = {
              "av_task": atom_vocab_label,
              "bv_task": bond_vocab_label,
              "fg_task": fg_task,
          }
          inputs = (
              f_atoms,
              f_bonds,
              a2b,
              b2a,
              b2revb,
              a_scope,
              b_scope,
              a2a,
          )
          return inputs, labels, w
  
      model._prepare_batch_for_pretraining = (
          _prepare_batch_for_pretraining
      )
      loss = model.fit(graph_data, nb_epoch=200)
      assert loss < 0.1
  
file_path: deepchem/deepchem/models/torch_models/tests/test_grover.py
imports: import os
  import pytest
  import numpy
  import deepchem
label_desc: Use image node_id 6 for calling a global function with example usage: test_grover_pretraining_task_overfit(tmpdir) and returns: inputs,  labels,  w