docstr: Pretraining stage
  As a matter of fact, it trains encoder, and decoder is just an auxiliary task
docstr_tok: ["Pretraining","stage","As","a","matter","of","fact",",","it","trains","encoder",",","and","decoder","is","just","an","auxiliary","task"]
code: def _train_pretraining_only(self, dataset, per_epoch=False):
      """
      Pretraining stage
      As a matter of fact, it trains encoder, and decoder is just an auxiliary task
      """
      import torch_geometric
  
      if int(torch_geometric.__version__.split(".")[0]) >= 2:
          # version 2.x
          from torch_geometric.loader import DataLoader
      else:
          from torch_geometric.data import DataLoader
      if self.graph_level:
          pre_train_loader = DataLoader(
              dataset,
              batch_size=self.batch_size,
              num_workers=self.num_workers,
              shuffle=True,
          )
      else:
          # TODO node level
          pre_train_loader = None
      optimizer = self.p_optimizer(
          self.encoder.encoder.parameters(),
          lr=self.p_lr,
          weight_decay=self.p_weight_decay,
      )
      optimizer.add_param_group(
          {"params": self.decoder.decoder.parameters()}
      )
      scheduler = self._get_scheduler("pretraining", optimizer)
      with trange(self.p_epoch) as t:
          for epoch in t:
              self.encoder.encoder.train()
              self.decoder.decoder.train()
              t.set_description(f"Pretraining: epoch {epoch + 1}")
              try:
                  epoch_loss, last_loss = self._get_loader_loss(
                      pre_train_loader, optimizer, scheduler, "train"
                  )
              except ValueError:
                  epoch_loss = 1e10
                  pass
              t.set_postfix(loss="{:.6f}".format(float(last_loss)))
              if per_epoch:
                  yield epoch
              else:
                  self.p_early_stopping(
                      epoch_loss, self.encoder.encoder
                  )
                  if self.p_early_stopping.early_stop:
                      LOGGER.debug("Early stopping at", epoch)
                      break
  
      if not per_epoch:
          self.p_early_stopping.load_checkpoint(self.encoder.encoder)
          yield self.p_epoch
  
imports: import os
  import torch
  import torch_geometric
  import logging
  import numpy
  import typing
  from tqdm import trange
  from typing import Union, Tuple, Sequence, Type, Callable
  import torch.nn.functional
  import torch.utils.data
  from torch.optim.lr_scheduler import StepLR, MultiStepLR, ExponentialLR, ReduceLROnPlateau
  from .losses import NTXent_loss
  from .utils import get_view_by_name
  from autogl.module.model.encoders.base_encoder import AutoHomogeneousEncoderMaintainer
  from ..base import BaseTrainer, EarlyStopping, _DummyModel
  from ..evaluation import Evaluation, get_feval, Acc
  from ...model import BaseAutoModel, BaseEncoderMaintainer, BaseDecoderMaintainer, EncoderUniversalRegistry, DecoderUniversalRegistry
  from ....utils import get_logger
  from ....datasets import utils
label_desc: Use image node_id 24 for calling the BaseContrastiveTrainer obj's underlying member method code with example usage: obj._train_pretraining_only(dataset, per_epoch) without return types