class_docstr: Implementation of control theory augment.
class_docstr_tok: ["Implementation","of","control","theory","augment","."]
docstr: Initialize CT Augment.
  
  Args:
    n: number of augmentations to perform per image.
    confidence_threshold: confidence threshold for probabilities.
    decay: exponential decay factor for augmentation rates.
    eps: small number to avoid numerical instabilities while computing probabilities.
    p: probability to apply an augmentation. If None then always apply.
    quantum: number of levels of quantization for the magnitude.
docstr_tok: ["Initialize","CT","Augment",".","Args",":","n",":","number","of","augmentations","to","perform","per","image",".","confidence_threshold",":","confidence","threshold","for","probabilities",".","decay",":","exponential","decay","factor","for","augmentation","rates",".","eps",":","small","number","to","avoid","numerical","instabilities","while","computing","probabilities",".","p",":","probability","to","apply","an","augmentation",".","If","None","then","always","apply",".","quantum",":","number","of","levels","of","quantization","for","the","magnitude","."]
code: def __init__(
      self,
      n: int = 2,
      confidence_threshold: float = 0.85,
      decay: float = 0.99,
      eps: float = 0.001,
      p: Optional[float] = None,
      quantum: int = 10,
  ):
      """Initialize CT Augment.
  
      Args:
        n: number of augmentations to perform per image.
        confidence_threshold: confidence threshold for probabilities.
        decay: exponential decay factor for augmentation rates.
        eps: small number to avoid numerical instabilities while computing probabilities.
        p: probability to apply an augmentation. If None then always apply.
        quantum: number of levels of quantization for the magnitude.
      """
      self.n = n
      self.confidence_threshold = float(confidence_threshold)
      self.decay = float(decay)
      self.alpha = 1.0 - self.decay
      self.eps = eps
      self.quantum = quantum
      self.p = p
      # State of the augmenter is defined by rates.
      # To speed up sampling we also keep separate variable for sampling
      # probabilities (log_probs) which are deterministically computed from rates.
      self.state_shape = [len(IMAGENET_AUG_OPS), self.quantum]
      # rates are updated using assign_add and averaged across all replicas.
      self.rates = tf.Variable(
          tf.ones(self.state_shape, dtype=tf.float32),
          trainable=False,
          name="cta_rates",
          aggregation=tf.VariableAggregation.MEAN,
          synchronization=tf.VariableSynchronization.ON_WRITE,
      )
      # log_probs is deterministically computed from rates and value should
      # be the same on all replicas, thus we use ONLY_FIRST_REPLICA aggregation
      self.probs = tf.Variable(
          tf.ones(self.state_shape, dtype=tf.float32) / self.quantum,
          trainable=False,
          name="cta_probs",
          aggregation=tf.VariableAggregation.ONLY_FIRST_REPLICA,
          synchronization=tf.VariableSynchronization.ON_WRITE,
      )
      # list of log probs variables for each data pipeline
      self.log_probs = []
  
imports: from typing import Optional
  import tensorflow
  from .randaugment import augment_ops
label_desc: Use image node_id 1 to create a new CTAugment object from inherited base classes: object with example: obj = CTAugment(n, confidence_threshold, decay, eps, p, quantum)