code: def split_train_val_unlabeled(
      train_inputs,
      train_labels,
      target_num_train_per_class,
      target_num_val,
      seed=None,
  ):
      """Splits the training data into train, validation and unlabeled samples.
  
      Args:
          train_inputs: A numpy array containing the training inputs, where the
            first dimension represents the samples.
          train_labels: A numpy array containing the training labels, where the
            first dimension represents the samples.
          target_num_train_per_class: An integer representing the number of samples
            from each class to keep for training.
          target_num_val: An integer representing the number of samples to keep for
            validation (in total). We do not make the selection per class.
          seed: Integer representing the seed for the random number generator that
            splits the data.
  
      Returns:
        train_inputs: A numpy array in the same format as `train_inputs` containing
          the new train inputs.
        train_labels: A numpy array in the same format as `train_labels` containing
          the new train labels.
        val_inputs: A numpy array in the same format as `train_inputs` containing
          the validation inputs.
        val_labels: A numpy array in the same format as `train_labels` containing
          the validation labels.
        unlabeled_inputs: A numpy array in the same format as `train_inputs`
          containing the inputs for the unlabeled nodes.
        unlabeled_labels: A numpy array in the same format as `train_labels`
          containing the labels of the samples that will be considered unlabeled.
      """
      num_train = train_inputs.shape[0]
      num_val = target_num_val
      num_classes = max(train_labels) + 1
  
      assert (
          target_num_val < num_train
      ), "Too many validation samples required."
  
      # Split the train samples into train and validation.
      ind = np.arange(0, num_train)
      rng = np.random.RandomState(seed)
      rng.shuffle(ind)
      ind_val = ind[:num_val]
      ind_train = ind[num_val:]
      val_inputs = train_inputs[ind_val]
      val_labels = train_labels[ind_val]
      train_inputs = train_inputs[ind_train]
      train_labels = train_labels[ind_train]
  
      # Out of the remaining training samples, select a fixed number of samples
      # from each class.
      ind_train = []
      for i in range(num_classes):
          ind_class = np.where(train_labels == i)[0]
          assert len(ind_class) >= target_num_train_per_class, (
              "Not enough labels for class %d to select %d labels per class. "
              "Please select a target_num_train_per_class flag lower than %d."
              % (i, target_num_train_per_class, len(ind_class))
          )
          rng.shuffle(ind_class)
          selected_ind = ind_class[:target_num_train_per_class]
          ind_train.extend(selected_ind)
  
      # Having selected the train indices, save the remaining unlabeled nodes in a
      # different group.
      set_ind_train = set(ind_train)
      num_train = num_train - num_val
      ind_unlabeled = [
          i for i in range(num_train) if i not in set_ind_train
      ]
      ind_train = np.asarray(ind_train)
      ind_unlabeled = np.asarray(ind_unlabeled)
      unlabeled_inputs = train_inputs[ind_unlabeled]
      unlabeled_labels = train_labels[ind_unlabeled]
      train_inputs = train_inputs[ind_train]
      train_labels = train_labels[ind_train]
  
      return (
          train_inputs,
          train_labels,
          val_inputs,
          val_labels,
          unlabeled_inputs,
          unlabeled_labels,
      )
  
imports: from __future__ import absolute_import
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: split_train_val_unlabeled(train_inputs, train_labels, target_num_train_per_class, target_num_val, seed) and returns: train_inputs,  train_labels,  val_inputs,  val_labels,  unlabeled_inputs,  unlabeled_labels