class_docstr: InfographStar is a semi-supervised graph convolutional network for predicting molecular properties.
  It aims to maximize the mutual information between the graph-level representation and the
  representations of substructures of different scales. It does this by producing graph-level
  encodings and substructure encodings, and then using a discriminator to classify if they
  are from the same molecule or not.
  
  Supervised training is done by using the graph-level encodings to predict the target property. Semi-supervised training is done by adding a loss term that maximizes the mutual information between the graph-level encodings and the substructure encodings to the supervised loss.
  These modes can be chosen by setting the training_mode parameter.
  
  To conduct training in unsupervised mode, use InfoGraphModel.
  
  References
  ----------
  .. [1] F.-Y. Sun, J. Hoffmann, V. Verma, and J. Tang, “InfoGraph: Unsupervised and Semi-supervised Graph-Level Representation Learning via Mutual Maximization.” arXiv, Jan. 17, 2020. http://arxiv.org/abs/1908.01000
  
  Parameters
  ----------
  num_features: int
      Number of node features for each input
  edge_features: int
      Number of edge features for each input
  embedding_dim: int
      Dimension of the embedding
  training_mode: str
      The mode to use for training. Options are 'supervised', 'semisupervised'. For unsupervised training, use InfoGraphModel.
  measure: str
      The divergence measure to use for the unsupervised loss. Options are 'GAN', 'JSD',
      'KL', 'RKL', 'X2', 'DV', 'H2', or 'W1'.
  average_loss: bool
      Whether to average the loss over the batch
  
  Examples
  --------
  >>> from deepchem.models.torch_models import InfoGraphStarModel
  >>> from deepchem.feat import MolGraphConvFeaturizer
  >>> from deepchem.data import NumpyDataset
  >>> import torch
  >>> smiles = ["C1CCC1", "C1=CC=CN=C1"]
  >>> featurizer = MolGraphConvFeaturizer(use_edges=True)
  >>> X = featurizer.featurize(smiles)
  >>> y = torch.randint(0, 2, size=(2, 1)).float()
  >>> w = torch.ones(size=(2, 1)).float()
  >>> ds = NumpyDataset(X, y, w)
  >>> num_feat = max([ds.X[i].num_node_features for i in range(len(ds))])
  >>> edge_dim = max([ds.X[i].num_edge_features for i in range(len(ds))])
  >>> model = InfoGraphStarModel(num_feat, edge_dim, 15, training_mode='semisupervised')
  >>> loss = model.fit(ds, nb_epoch=1)
code: def __init__(
      self,
      num_features,
      edge_features,
      embedding_dim,
      task: Literal["supervised", "semisupervised"] = "supervised",
      mode: Literal["regression", "classification"] = "regression",
      num_classes=2,
      num_tasks=1,
      measure="JSD",
      average_loss=True,
      num_gc_layers=5,
      **kwargs,
  ):
      assert task in [
          "supervised",
          "semisupervised",
      ], "Invalid model task"
      assert mode in [
          "regression",
          "classification",
      ], "Invalid model mode"
      self.edge_features = edge_features
      self.local = True
      self.prior = False
      self.gamma = 0.1
      self.num_features = num_features
      self.task = task
      self.mode = mode
      self.num_classes = num_classes
      if self.mode == "regression":
          self.output_dim = num_tasks
      elif self.mode == "classification":
          self.num_tasks = num_tasks
          self.output_dim = num_classes * num_tasks
          self.class_loss = SoftmaxCrossEntropy()._create_pytorch_loss()
      if self.task == "supervised":
          self.embedding_dim = embedding_dim
      elif self.task == "semisupervised":
          self.embedding_dim = embedding_dim * num_gc_layers
          self.num_gc_layers = num_gc_layers
      self.localloss = (
          LocalMutualInformationLoss()._create_pytorch_loss(
              measure, average_loss
          )
      )
      self.globalloss = (
          GlobalMutualInformationLoss()._create_pytorch_loss(
              measure, average_loss
          )
      )
  
      self.components = self.build_components()
      self.model = self.build_model()
      super().__init__(self.model, self.components, **kwargs)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn import GRU, Linear, ReLU, Sequential
  from typing import Iterable, List, Tuple, Optional, Dict, Literal
  from deepchem.metrics import to_one_hot
  import deepchem
  from deepchem.models.losses import SoftmaxCrossEntropy
  from deepchem.feat.graph_data import BatchGraphData
  from deepchem.models.losses import GlobalMutualInformationLoss, LocalMutualInformationLoss
  from deepchem.models.torch_models.layers import MultilayerPerceptron
  from deepchem.models.torch_models.modular import ModularTorchModel
label_desc: Use image node_id 1 to create a new InfoGraphStarModel object from inherited base classes: ModularTorchModel with example: obj = InfoGraphStarModel(num_features, edge_features, embedding_dim, task, mode, num_classes, num_tasks, measure, average_loss, num_gc_layers)