class_docstr: Trainer for the classifier component of a Graph Agreement Model.
  
  Attributes:
    model: A Model object that is used to provide the architecture of the
      classification model.
    is_train: A placeholder for a boolean value specyfing if the model is used
      for train or evaluation.
    data: A CotrainDataset object.
    trainer_agr: A TrainerAgreement or TrainerPerfectAgreement object.
    optimizer: Optimizer used for training the classification model.
    batch_size: Batch size for used when training and evaluating the
      classification model.
    gradient_clip: A float number representing the maximum gradient norm allowed
      if we do gradient clipping. If None, no gradient clipping is performed.
    min_num_iter: An integer representing the minimum number of iterations to
      train the classification model.
    max_num_iter: An integer representing the maximum number of iterations to
      train the classification model.
    num_iter_after_best_val: An integer representing the number of extra
      iterations to perform after improving the validation set accuracy.
    max_num_iter_cotrain: An integer representing the maximum number of cotrain
      iterations to train for.
    reg_weight_ll: A float representing the weight of the agreement loss term
      component of the classification model loss function, between
      labeled-labeled pairs of samples.
    reg_weight_lu: A float representing the weight of the agreement loss term
      component of the classification model loss function, between
      labeled-unlabeled pairs of samples.
    reg_weight_uu: A float representing the weight of the agreement loss term
      component of the classification model loss function, between
      unlabeled-unlabeled pairs of samples.
    num_pairs_reg: An integer representing the number of sample pairs of each
      type (LL, LU, UU) to include in each computation of the classification
      model loss.
    iter_cotrain: A Tensorflow variable containing the current cotrain
      iteration.
    reg_weight_vat: A float representing the weight of the virtual adversarial
      training (VAT) regularization loss in the classification model loss
      function.
    use_ent_min: A boolean specifying whether to use entropy regularization with
      VAT.
    enable_summaries: Boolean specifying whether to enable variable summaries.
    summary_step: Integer representing the summary step size.
    summary_dir: String representing the path to a directory where to save the
      variable summaries.
    logging_step: Integer representing the number of iterations after which we
      log the loss of the model.
    eval_step: Integer representing the number of iterations after which we
      evaluate the model.
    warm_start: Whether the model parameters are initialized at their best value
      in the previous cotrain iteration. If False, they are reinitialized.
      gradient_clip=None,
    abs_loss_chg_tol: A float representing the absolute tolerance for checking
      if the training loss has converged. If the difference between the current
      loss and previous loss is less than `abs_loss_chg_tol`, we count this
      iteration towards convergence (see `loss_chg_iter_below_tol`).
    rel_loss_chg_tol: A float representing the relative tolerance for checking
      if the training loss has converged. If the ratio between the current loss
      and previous loss is less than `rel_loss_chg_tol`, we count this iteration
      towards convergence (see `loss_chg_iter_below_tol`).
    loss_chg_iter_below_tol: An integer representing the number of consecutive
      iterations that pass the convergence criteria before stopping training.
    checkpoints_dir: Path to the folder where to store TensorFlow model
      checkpoints.
    weight_decay: Weight for the weight decay term in the classification model
      loss.
    weight_decay_schedule: Schedule how to adjust the classification weight
      decay weight after every cotrain iteration.
    penalize_neg_agr: Whether to not only encourage agreement between samples
      that the agreement model believes should have the same label, but also
      penalize agreement when two samples agree when the agreement model
      predicts they should disagree.
    first_iter_original:  A boolean specifying whether the first cotrain
      iteration trains the original classification model (with no agreement
      term).
    use_l2_classif: Whether to use L2 loss for classification, as opposed to the
      whichever loss is specified in the provided model_cls.
    seed: Seed used by all the random number generators in this class.
    use_graph: Boolean specifying whether the agreement loss is applied to graph
      edges, as opposed to random pairs of samples.
docstr: An iterator over graph edges.
  
  Args:
    data: A CotrainDataset object used to extract the features and labels.
    batch_size:  An integer representing the desired batch size.
    labeling: A string which can be `ll`, `lu` or `uu`, that is used to
      represent the type of edges to return, where `ll` refers to
      labeled-labeled, `lu` refers to labeled-unlabeled, and `uu` refers to
      unlabeled-unlabeled.
  
  Yields:
    indices_src, indices_tgt, features_src, features_tgt, labels_src,
    labels_tgt
docstr_tok: ["An","iterator","over","graph","edges",".","Args",":","data",":","A","CotrainDataset","object","used","to","extract","the","features","and","labels",".","batch_size",":","An","integer","representing","the","desired","batch","size",".","labeling",":","A","string","which","can","be","`","ll","`",",","`","lu","`","or","`","uu","`",",","that","is","used","to","represent","the","type","of","edges","to","return",",","where","`","ll","`","refers","to","labeled-labeled",",","`","lu","`","refers","to","labeled-unlabeled",",","and","`","uu","`","refers","to","unlabeled-unlabeled",".","Yields",":","indices_src",",","indices_tgt",",","features_src",",","features_tgt",",","labels_src",",","labels_tgt"]
code: def edge_iterator(self, data, batch_size, labeling):
      """An iterator over graph edges.
  
      Args:
        data: A CotrainDataset object used to extract the features and labels.
        batch_size:  An integer representing the desired batch size.
        labeling: A string which can be `ll`, `lu` or `uu`, that is used to
          represent the type of edges to return, where `ll` refers to
          labeled-labeled, `lu` refers to labeled-unlabeled, and `uu` refers to
          unlabeled-unlabeled.
  
      Yields:
        indices_src, indices_tgt, features_src, features_tgt, labels_src,
        labels_tgt
      """
      if labeling == "ll":
          edges = data.get_edges(
              src_labeled=True, tgt_labeled=True, label_must_match=True
          )
      elif labeling == "lu":
          edges_lu = data.get_edges(src_labeled=True, tgt_labeled=False)
          edges_ul = data.get_edges(src_labeled=False, tgt_labeled=True)
          # Reverse the edges of UL to be LU.
          edges_ul = [e.copy(src=e.tgt, tgt=e.src) for e in edges_ul]
          edges = edges_lu + edges_ul
      elif labeling == "uu":
          edges = data.get_edges(src_labeled=False, tgt_labeled=False)
      else:
          raise ValueError(
              "Unsupported value for parameter `labeling`."
          )
  
      if not edges:
          indices = np.zeros(shape=(0,), dtype=np.int32)
          features = np.zeros(
              shape=[
                  0,
              ]
              + list(data.features_shape),
              dtype=np.float32,
          )
          labels = np.zeros(shape=(0,), dtype=np.int64)
          while True:
              yield (
                  indices,
                  indices,
                  features,
                  features,
                  labels,
                  labels,
              )
  
      edges = np.stack([(e.src, e.tgt) for e in edges])
      iterator = batch_iterator(
          inputs=edges,
          batch_size=batch_size,
          shuffle=True,
          allow_smaller_batch=False,
          repeat=True,
      )
  
      for edge in iterator:
          indices_src = edge[:, 0]
          indices_tgt = edge[:, 1]
          features_src = data.get_features(indices_src)
          features_tgt = data.get_features(indices_tgt)
          labels_src = data.get_labels(indices_src)
          labels_tgt = data.get_labels(indices_tgt)
          yield (
              indices_src,
              indices_tgt,
              features_src,
              features_tgt,
              labels_src,
              labels_tgt,
          )
  
imports: import logging
  import os
  from .adversarial_dense import entropy_y_x
  from .adversarial_dense import get_loss_vat
  import numpy
  import tensorflow
  from .trainer_base import batch_iterator
  from .trainer_base import Trainer
label_desc: Use image node_id 7 for calling the TrainerClassification obj's underlying member method code with example usage: obj.edge_iterator(data, batch_size, labeling) without return types