class_docstr: This class implements the Graphair model
  
  :param aug_model: The augmentation model g described in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ used for automated graph augmentations
  :type aug_model: :obj:`torch.nn.Module`
  
  :param f_encoder: The represnetation encoder f described in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ used for contrastive learning
  :type f_encoder: :obj:`torch.nn.Module`
  
  :param sens_model: The adversary model k described in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ used for adversarial learning
  :type sens_model: :obj:`torch.nn.Module`
  
  :param classifier_model: The classifier used to predict the sensitive label of nodes on the augmented graph data.
  :type classifier_model: :obj:`torch.nn.Module`
  
  :param lr: Learning rate for aug_model, f_encoder and sens_model. Defaults to 1e-4
  :type lr: float,optional
  
  :param weight_decay: Weight decay for regularization. Defaults to 1e-5
  :type weight_decay: float,optional
  
  :param alpha: The hyperparameter alpha used in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ to scale adversarial loss component. Defaults to 20.0
  :type alpha: float,optional
  
  :param beta: The hyperparameter beta used in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ to scale contrastive loss component. Defaults to 0.9
  :type beta: float,optional
  
  :param gamma: The hyperparameter gamma used in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ to scale reconstruction loss component. Defaults to 0.7
  :type gamma: float,optional
  
  :param lam: The hyperparameter lambda used in the `paper <https://openreview.net/forum?id=1_OGWcP1s9w>`_ to compute reconstruction loss component. Defaults to 1.0
  :type lam: float,optional
  
  :param dataset: The name of the dataset being used. Used only for the model's output path. Defaults to 'POKEC'
  :type dataset: str,optional
  
  :param num_hidden: The input dimension for the MLP networks used in the model. Defaults to 64
  :type num_hidden: int,optional
  
  :param num_proj_hidden: The output dimension for the MLP networks used in the model. Defaults to 64
  :type num_proj_hidden: int,optional
class_docstr_tok: ["This","class","implements","the","Graphair","model",":","param","aug_model",":","The","augmentation","model","g","described","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","used","for","automated","graph","augmentations",":","type","aug_model",":",":","obj",":","`","torch.nn.Module","`",":","param","f_encoder",":","The","represnetation","encoder","f","described","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","used","for","contrastive","learning",":","type","f_encoder",":",":","obj",":","`","torch.nn.Module","`",":","param","sens_model",":","The","adversary","model","k","described","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","used","for","adversarial","learning",":","type","sens_model",":",":","obj",":","`","torch.nn.Module","`",":","param","classifier_model",":","The","classifier","used","to","predict","the","sensitive","label","of","nodes","on","the","augmented","graph","data",".",":","type","classifier_model",":",":","obj",":","`","torch.nn.Module","`",":","param","lr",":","Learning","rate","for","aug_model",",","f_encoder","and","sens_model",".","Defaults","to","1e-4",":","type","lr",":","float",",","optional",":","param","weight_decay",":","Weight","decay","for","regularization",".","Defaults","to","1e-5",":","type","weight_decay",":","float",",","optional",":","param","alpha",":","The","hyperparameter","alpha","used","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","to","scale","adversarial","loss","component",".","Defaults","to","20.0",":","type","alpha",":","float",",","optional",":","param","beta",":","The","hyperparameter","beta","used","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","to","scale","contrastive","loss","component",".","Defaults","to","0.9",":","type","beta",":","float",",","optional",":","param","gamma",":","The","hyperparameter","gamma","used","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","to","scale","reconstruction","loss","component",".","Defaults","to","0.7",":","type","gamma",":","float",",","optional",":","param","lam",":","The","hyperparameter","lambda","used","in","the","`","paper","<","https",":","\/\/openreview.net\/forum","?","id=1_OGWcP1s9w",">","`","_","to","compute","reconstruction","loss","component",".","Defaults","to","1.0",":","type","lam",":","float",",","optional",":","param","dataset",":","The","name","of","the","dataset","being","used",".","Used","only","for","the","model","'s","output","path",".","Defaults","to","'POKEC'",":","type","dataset",":","str",",","optional",":","param","num_hidden",":","The","input","dimension","for","the","MLP","networks","used","in","the","model",".","Defaults","to","64",":","type","num_hidden",":","int",",","optional",":","param","num_proj_hidden",":","The","output","dimension","for","the","MLP","networks","used","in","the","model",".","Defaults","to","64",":","type","num_proj_hidden",":","int",",","optional"]
code: def __init__(
      self,
      aug_model,
      f_encoder,
      sens_model,
      classifier_model,
      lr=1e-4,
      weight_decay=1e-5,
      alpha=20,
      beta=0.9,
      gamma=0.7,
      lam=1,
      dataset="POKEC",
      num_hidden=64,
      num_proj_hidden=64,
  ):
      super(graphair, self).__init__()
      self.aug_model = aug_model
      self.f_encoder = f_encoder
      self.sens_model = sens_model
      self.classifier = classifier_model
      self.alpha = alpha
      self.beta = beta
      self.gamma = gamma
      self.dataset = dataset
      self.lam = lam
  
      self.criterion_sens = nn.BCEWithLogitsLoss()
      self.criterion_cont = nn.CrossEntropyLoss()
      self.criterion_recons = nn.MSELoss()
  
      self.optimizer_s = torch.optim.Adam(
          self.sens_model.parameters(), lr=1e-4, weight_decay=1e-5
      )
  
      FG_params = [
          {"params": self.aug_model.parameters(), "lr": 1e-4},
          {"params": self.f_encoder.parameters()},
      ]
      self.optimizer = torch.optim.Adam(
          FG_params, lr=lr, weight_decay=weight_decay
      )
  
      self.optimizer_aug = torch.optim.Adam(
          self.aug_model.parameters(),
          lr=1e-3,
          weight_decay=weight_decay,
      )
      self.optimizer_enc = torch.optim.Adam(
          self.f_encoder.parameters(), lr=lr, weight_decay=weight_decay
      )
  
      self.fc1 = torch.nn.Linear(num_hidden, num_proj_hidden)
      self.fc2 = torch.nn.Linear(num_proj_hidden, num_hidden)
  
      self.optimizer_classifier = torch.optim.Adam(
          self.classifier.parameters(), lr=lr, weight_decay=weight_decay
      )
  
file_path: DIG/dig/fairgraph/method/Graphair/graphair.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  import scipy.sparse
  import numpy
  from dig.fairgraph.utils.utils import scipysp_to_pytorchsp, accuracy, fair_metric
label_desc: Use image node_id 1 to create a new graphair object from inherited base classes: nn with example: obj = graphair(aug_model, f_encoder, sens_model, classifier_model, lr, weight_decay, alpha, beta, gamma, lam, dataset, num_hidden, num_proj_hidden)