docstr: The function of duplicating a new instance from the given hyperparameter.
  
  Parameters
  ----------
  hp: `dict`
      The hyperparameter used in the new instance. Should contain 4 keys "trainer", "encoder"
      "decoder" and "phead", with corresponding hyperparameters as values.
  
  encoder: `str` or `autogl.module.model.encoders.BaseEncoderMaintainer`
      The new encoder
  
  decoder: `str` or `autogl.module.model.decoders.BaseDecoderMaintainer`
      The new decoder
  
  prediction_head: `str` or `autogl.module.model.decoders.BaseDecoderMaintainer`
      The new predictor
  
  restricted: `bool`
      If False(True), the hyperparameter should (not) be updated from origin hyperparameter.
  
  Returns
  -------
  self: `autogl.train.ssl.GraphCLSemisupervisedTrainer`
      A new instance of trainer.
docstr_tok: ["The","function","of","duplicating","a","new","instance","from","the","given","hyperparameter",".","Parameters","--","--","--","--","--","hp",":","`","dict","`","The","hyperparameter","used","in","the","new","instance",".","Should","contain","4","keys","``","trainer","''",",","``","encoder","''","``","decoder","''","and","``","phead","''",",","with","corresponding","hyperparameters","as","values",".","encoder",":","`","str","`","or","`","autogl.module.model.encoders.BaseEncoderMaintainer","`","The","new","encoder","decoder",":","`","str","`","or","`","autogl.module.model.decoders.BaseDecoderMaintainer","`","The","new","decoder","prediction_head",":","`","str","`","or","`","autogl.module.model.decoders.BaseDecoderMaintainer","`","The","new","predictor","restricted",":","`","bool","`","If","False","(","True",")",",","the","hyperparameter","should","(","not",")","be","updated","from","origin","hyperparameter",".","Returns","--","--","--","-","self",":","`","autogl.train.ssl.GraphCLSemisupervisedTrainer","`","A","new","instance","of","trainer","."]
code: def duplicate_from_hyper_parameter(
      self,
      hp,
      encoder="same",
      decoder="same",
      prediction_head="same",
      restricted=True,
  ):
      """
      The function of duplicating a new instance from the given hyperparameter.
  
      Parameters
      ----------
      hp: `dict`
          The hyperparameter used in the new instance. Should contain 4 keys "trainer", "encoder"
          "decoder" and "phead", with corresponding hyperparameters as values.
  
      encoder: `str` or `autogl.module.model.encoders.BaseEncoderMaintainer`
          The new encoder
  
      decoder: `str` or `autogl.module.model.decoders.BaseDecoderMaintainer`
          The new decoder
  
      prediction_head: `str` or `autogl.module.model.decoders.BaseDecoderMaintainer`
          The new predictor
  
      restricted: `bool`
          If False(True), the hyperparameter should (not) be updated from origin hyperparameter.
  
      Returns
      -------
      self: `autogl.train.ssl.GraphCLSemisupervisedTrainer`
          A new instance of trainer.
  
      """
      hp_trainer = hp.get("trainer", {})
      hp_encoder = hp.get("encoder", {})
      hp_decoder = hp.get("decoder", {})
      hp_phead = hp.get("prediction_head", {})
      if not restricted:
          origin_hp = deepcopy(self.hyper_parameters)
          origin_hp.update(hp_trainer)
          hp = origin_hp
      else:
          hp = hp_trainer
      encoder = encoder if encoder != "same" else self.encoder
      decoder = decoder if decoder != "same" else self.decoder
      prediction_head = (
          prediction_head
          if prediction_head != "same"
          else self.prediction_head
      )
      encoder = encoder.from_hyper_parameter(hp_encoder)
      decoder.output_dimension = tuple(encoder.get_output_dimensions())[
          -1
      ]
      if isinstance(encoder, BaseEncoderMaintainer) and isinstance(
          decoder, BaseDecoderMaintainer
      ):
          decoder = decoder.from_hyper_parameter_and_encoder(
              hp_decoder, encoder
          )
      if isinstance(encoder, BaseEncoderMaintainer) and isinstance(
          prediction_head, BaseDecoderMaintainer
      ):
          prediction_head = (
              prediction_head.from_hyper_parameter_and_encoder(
                  hp_phead, encoder
              )
          )
      ret = self.__class__(
          model=(encoder, decoder),
          prediction_head=prediction_head,
          num_features=self.num_features,
          num_classes=self.num_classes,
          num_graph_features=self.num_graph_features,
          device=self.device,
          feval=self.feval,
          loss=self.loss,
          f_loss=self.f_loss,
          views_fn=self.views_fn_opt,
          aug_ratio=self.aug_ratio,
          z_dim=self.last_dim,
          tau=self.tau,
          model_path=self.model_path,
          num_workers=self.num_workers,
          batch_size=hp["batch_size"],
          p_optim=self.p_opt_received,
          p_lr=hp["p_lr"],
          p_lr_scheduler_type=self.p_lr_scheduler_type,
          p_epoch=hp["p_epoch"],
          p_early_stopping_round=hp["p_early_stopping_round"],
          p_weight_decay=hp["p_weight_decay"],
          f_optim=self.f_opt_received,
          f_lr=hp["f_lr"],
          f_lr_scheduler_type=self.f_lr_scheduler_type,
          f_epoch=hp["f_epoch"],
          f_early_stopping_round=hp["f_early_stopping_round"],
          f_weight_decay=hp["f_weight_decay"],
          init=True,
          *self.args,
          **self.kwargs,
      )
  
      return ret
  
imports: import os
  import torch
  import logging
  import torch.nn.functional
  import torch.utils.data
  import numpy
  import typing
  import torch.multiprocessing
  from typing import Union, Tuple, Sequence, Type, Callable
  from tqdm import trange
  from copy import deepcopy
  from .base import BaseContrastiveTrainer
  from ..None import register_trainer
  from ..base import EarlyStopping, _DummyModel
  from ..evaluation import Evaluation, get_feval, Acc
  from ...model import BaseAutoModel, BaseEncoderMaintainer, BaseDecoderMaintainer, DecoderUniversalRegistry
  from ....datasets import utils
  from ....utils import get_logger
  from torch_geometric.nn.glob import global_add_pool, global_max_pool, global_mean_pool
label_desc: Use image node_id 10 for calling the GraphCLSemisupervisedTrainer obj's underlying member method code with example usage: obj.duplicate_from_hyper_parameter(hp, encoder, decoder, prediction_head, restricted) and returns: ret