docstr: The function of training on the given dataset and keeping valid result.
  
  Parameters
  ----------
  dataset: The graph dataset used to be trained.
  keep_valid_result: `bool`
      if True, save the validation result after training.
  
  Returns
  -------
  self: `autogl.train.GraphCLSemisupervisedTrainer`
      A reference of current trainer.
docstr_tok: ["The","function","of","training","on","the","given","dataset","and","keeping","valid","result",".","Parameters","--","--","--","--","--","dataset",":","The","graph","dataset","used","to","be","trained",".","keep_valid_result",":","`","bool","`","if","True",",","save","the","validation","result","after","training",".","Returns","--","--","--","-","self",":","`","autogl.train.GraphCLSemisupervisedTrainer","`","A","reference","of","current","trainer","."]
code: def train(self, dataset, keep_valid_result=True):
      """
      The function of training on the given dataset and keeping valid result.
  
      Parameters
      ----------
      dataset: The graph dataset used to be trained.
      keep_valid_result: `bool`
          if True, save the validation result after training.
  
      Returns
      -------
      self: `autogl.train.GraphCLSemisupervisedTrainer`
          A reference of current trainer.
  
      """
      try:
          if self.graph_level:
              valid_loader = utils.graph_get_split(
                  dataset,
                  "val",
                  batch_size=self.batch_size,
                  num_workers=self.num_workers,
              )
          else:
              # TODO node_level
              valid_loader = None
      except ValueError:
          valid_loader = None
      except AttributeError:
          valid_loader = None
      self._train_only(dataset)
      if keep_valid_result and valid_loader:
          # save the validation result after training
          pred = self._predict_only(valid_loader)
          self.valid_result = pred.max(1)[1]
          self.valid_result_prob = pred
          self.valid_score = self.evaluate(
              dataset, mask="val", feval=self.feval
          )
  
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 19 for calling the BaseContrastiveTrainer obj's underlying member method code with example usage: obj.train(dataset, keep_valid_result) without return types