class_docstr: The link prediction trainer.
  
  Used to automatically train the link prediction problem.
  
  Parameters
  ----------
  model:
      Models can be ``str``, ``autogl.module.model.BaseAutoModel``, 
      ``autogl.module.model.encoders.BaseEncoderMaintainer`` or a tuple of (encoder, decoder) 
      if need to specify both encoder and decoder. Encoder can be ``str`` or
      ``autogl.module.model.encoders.BaseEncoderMaintainer``, and decoder can be ``str``
      or ``autogl.module.model.decoders.BaseDecoderMaintainer``.
      If only encoder is specified, decoder will be default to "logsoftmax"
  
  num_features: int (Optional)
      The number of features in dataset. default None
  
  optimizer: ``Optimizer`` of ``str``
      The (name of) optimizer used to train and predict. default torch.optim.Adam
  
  lr: ``float``
      The learning rate of node classification task. default 1e-4
  
  max_epoch: ``int``
      The max number of epochs in training. default 100
  
  early_stopping_round: ``int``
      The round of early stop. default 100
  
  weight_decay: ``float``
      weight decay ratio, default 1e-4
  
  device: ``torch.device`` or ``str``
      The device where model will be running on.
  
  init: ``bool``
      If True(False), the model will (not) be initialized.
  
  feval: (Sequence of) ``Evaluation`` or ``str``
      The evaluation functions, default ``[LogLoss]``
  
  loss: ``str``
      The loss used. Default ``nll_loss``.
  
  lr_scheduler_type: ``str`` (Optional)
      The lr scheduler type used. Default None.
class_docstr_tok: ["The","link","prediction","trainer",".","Used","to","automatically","train","the","link","prediction","problem",".","Parameters","--","--","--","--","--","model",":","Models","can","be","``","str","``",",","``","autogl.module.model.BaseAutoModel","``",",","``","autogl.module.model.encoders.BaseEncoderMaintainer","``","or","a","tuple","of","(","encoder",",","decoder",")","if","need","to","specify","both","encoder","and","decoder",".","Encoder","can","be","``","str","``","or","``","autogl.module.model.encoders.BaseEncoderMaintainer","``",",","and","decoder","can","be","``","str","``","or","``","autogl.module.model.decoders.BaseDecoderMaintainer","``",".","If","only","encoder","is","specified",",","decoder","will","be","default","to","``","logsoftmax","''","num_features",":","int","(","Optional",")","The","number","of","features","in","dataset",".","default","None","optimizer",":","``","Optimizer","``","of","``","str","``","The","(","name","of",")","optimizer","used","to","train","and","predict",".","default","torch.optim.Adam","lr",":","``","float","``","The","learning","rate","of","node","classification","task",".","default","1e-4","max_epoch",":","``","int","``","The","max","number","of","epochs","in","training",".","default","100","early_stopping_round",":","``","int","``","The","round","of","early","stop",".","default","100","weight_decay",":","``","float","``","weight","decay","ratio",",","default","1e-4","device",":","``","torch.device","``","or","``","str","``","The","device","where","model","will","be","running","on",".","init",":","``","bool","``","If","True","(","False",")",",","the","model","will","(","not",")","be","initialized",".","feval",":","(","Sequence","of",")","``","Evaluation","``","or","``","str","``","The","evaluation","functions",",","default","``","[","LogLoss","]","``","loss",":","``","str","``","The","loss","used",".","Default","``","nll_loss","``",".","lr_scheduler_type",":","``","str","``","(","Optional",")","The","lr","scheduler","type","used",".","Default","None","."]
code: def __init__(
      self,
      model: Union[
          Tuple[BaseEncoderMaintainer, BaseDecoderMaintainer],
          BaseEncoderMaintainer,
          BaseAutoModel,
          str,
      ] = None,
      num_features=None,
      optimizer=torch.optim.Adam,
      lr=1e-4,
      max_epoch=100,
      early_stopping_round=101,
      weight_decay=1e-4,
      device="auto",
      init=False,
      feval=[Auc],
      loss="binary_cross_entropy_with_logits",
      lr_scheduler_type=None,
      *args,
      **kwargs,
  ):
      if isinstance(model, Tuple):
          encoder, decoder = model
      elif isinstance(model, BaseAutoModel):
          encoder, decoder = model, None
      else:
          encoder, decoder = model, "lp-decoder"
      super().__init__(
          encoder, decoder, num_features, "auto", device, feval, loss
      )
  
      self.opt_received = optimizer
      if isinstance(optimizer, str):
          if optimizer.lower() == "adam":
              self.optimizer = torch.optim.Adam
          elif optimizer.lower() == "sgd":
              self.optimizer = torch.optim.SGD
          else:
              raise ValueError(
                  "Currently not support optimizer {}".format(optimizer)
              )
      elif isinstance(optimizer, type) and issubclass(
          optimizer, torch.optim.Optimizer
      ):
          self.optimizer = optimizer
      else:
          raise ValueError(
              "Currently not support optimizer {}".format(optimizer)
          )
  
      self.lr_scheduler_type = lr_scheduler_type
  
      self.lr = lr
      self.max_epoch = max_epoch
      self.early_stopping_round = early_stopping_round
      self.args = args
      self.kwargs = kwargs
      self.weight_decay = weight_decay
  
      self.early_stopping = EarlyStopping(
          patience=early_stopping_round, verbose=False
      )
  
      self.valid_result = None
      self.valid_result_prob = None
      self.valid_score = None
  
      self.pyg_dgl = DependentBackend.get_backend_name()
  
      self.hyper_parameter_space = [
          {
              "parameterName": "max_epoch",
              "type": "INTEGER",
              "maxValue": 500,
              "minValue": 10,
              "scalingType": "LINEAR",
          },
          {
              "parameterName": "early_stopping_round",
              "type": "INTEGER",
              "maxValue": 30,
              "minValue": 10,
              "scalingType": "LINEAR",
          },
          {
              "parameterName": "lr",
              "type": "DOUBLE",
              "maxValue": 1e-1,
              "minValue": 1e-4,
              "scalingType": "LOG",
          },
          {
              "parameterName": "weight_decay",
              "type": "DOUBLE",
              "maxValue": 1e-2,
              "minValue": 1e-4,
              "scalingType": "LOG",
          },
      ]
  
      self.hyper_parameters = {
          "max_epoch": self.max_epoch,
          "early_stopping_round": self.early_stopping_round,
          "lr": self.lr,
          "weight_decay": self.weight_decay,
      }
  
      if init is True:
          self.initialize()
  
imports: from .None import register_trainer, Evaluation
  import torch
  from torch.optim.lr_scheduler import StepLR, MultiStepLR, ExponentialLR, ReduceLROnPlateau
  import torch.nn.functional
  from ..model import BaseEncoderMaintainer, BaseDecoderMaintainer, BaseAutoModel
  from .evaluation import Auc, EVALUATE_DICT
  from .base import EarlyStopping, BaseLinkPredictionTrainer
  from typing import Union, Tuple
  from copy import deepcopy
  from ...utils import get_logger
  from ...backend import DependentBackend
label_desc: Use image node_id 1 to create a new LinkPredictionTrainer object from inherited base classes: BaseLinkPredictionTrainer with example: obj = LinkPredictionTrainer(model, num_features, optimizer, lr, max_epoch, early_stopping_round, weight_decay, device, init, feval, loss, lr_scheduler_type)