docstr: Describes the augmentation policy as introduced in AutoAugment
  (https://arxiv.org/abs/1805.09501).
  
  Args
  ----
  name : str
      A name of the policy, for presentation purposes.
  num_magnitude_bins : int
      The number of bins that augmentations' magnitude ranges should be divided into.
  sub_policies: Sequence[Sequence[Tuple[Augmentation, float, Optional[int]]]]
      A list of sequences of transformations. For each processed sample, one of the
      sequences is chosen uniformly at random. Then, the tuples from the sequence
      are considered one by one. Each tuple describes what augmentation to apply at
      that point, what is the probability of skipping the augmentation at that time
      and what magnitude to use with the augmentation.
docstr_tok: ["Describes","the","augmentation","policy","as","introduced","in","AutoAugment","(","https",":","\/\/arxiv.org\/abs\/1805.09501",")",".","Args","--","--","name",":","str","A","name","of","the","policy",",","for","presentation","purposes",".","num_magnitude_bins",":","int","The","number","of","bins","that","augmentations","'","magnitude","ranges","should","be","divided","into",".","sub_policies",":","Sequence","[","Sequence","[","Tuple","[","Augmentation",",","float",",","Optional","[","int","]","]","]","]","A","list","of","sequences","of","transformations",".","For","each","processed","sample",",","one","of","the","sequences","is","chosen","uniformly","at","random",".","Then",",","the","tuples","from","the","sequence","are","considered","one","by","one",".","Each","tuple","describes","what","augmentation","to","apply","at","that","point",",","what","is","the","probability","of","skipping","the","augmentation","at","that","time","and","what","magnitude","to","use","with","the","augmentation","."]
code: def __init__(
      self,
      name: str,
      num_magnitude_bins: int,
      sub_policies: Sequence[
          Sequence[Tuple[Augmentation, float, Optional[int]]]
      ],
  ):
      """
      Describes the augmentation policy as introduced in AutoAugment
      (https://arxiv.org/abs/1805.09501).
  
      Args
      ----
      name : str
          A name of the policy, for presentation purposes.
      num_magnitude_bins : int
          The number of bins that augmentations' magnitude ranges should be divided into.
      sub_policies: Sequence[Sequence[Tuple[Augmentation, float, Optional[int]]]]
          A list of sequences of transformations. For each processed sample, one of the
          sequences is chosen uniformly at random. Then, the tuples from the sequence
          are considered one by one. Each tuple describes what augmentation to apply at
          that point, what is the probability of skipping the augmentation at that time
          and what magnitude to use with the augmentation.
      """
      self.name = name
      self.num_magnitude_bins = num_magnitude_bins
      if (
          not isinstance(num_magnitude_bins, int)
          or num_magnitude_bins < 1
      ):
          raise Exception(
              f"The `num_magnitude_bins` must be a positive integer, got {num_magnitude_bins}."
          )
      if not isinstance(sub_policies, (list, tuple)):
          raise Exception(
              f"The `sub_policies` must be a list or tuple of sub policies, "
              f"got {type(sub_policies)}."
          )
      for sub_policy in sub_policies:
          if not isinstance(sub_policy, (list, tuple)):
              raise Exception(
                  f"Each sub policy must be a list or tuple, got {sub_policy}."
              )
          for op_desc in sub_policy:
              if (
                  not isinstance(op_desc, (list, tuple))
                  or len(op_desc) != 3
              ):
                  raise Exception(
                      f"Each operation in sub policy must be specified as a triple: "
                      f"(augmentation, probability, magnitude). Got {op_desc}."
                  )
              aug, p, mag = op_desc
              if not isinstance(aug, Augmentation):
                  raise Exception(
                      f"Each augmentation in sub policies must be an instance of "
                      f"Augmentation. Got `{aug}`. Did you forget to use `@augmentation` "
                      f"decorator?"
                  )
              if not isinstance(p, (float, int)) or not 0 <= p <= 1:
                  raise Exception(
                      f"Probability of applying the augmentation must be a number from "
                      f"`[0, 1]` range. Got `{p}` for augmentation `{aug.name}`."
                  )
              if p == 0:
                  warnings.warn(
                      f"The augmentation `{aug.name}` in policy `{name}` is used with "
                      f"probability 0 in one of the sub-policies."
                  )
              if mag is None:
                  if aug.mag_range is not None:
                      raise Exception(
                          f"The augmentation `{aug.name}` has `mag_range` specified, so the "
                          f"magnitude bin is required. However, got `None` in the policy "
                          f"`{name}`."
                      )
              else:
                  if aug.mag_range is None:
                      warnings.warn(
                          f"The magnitude bin `{mag}` for augmentation `{aug.name}` in policy "
                          f"`{name}` will be ignored. The augmentation does not accept "
                          f"magnitudes (as it has no `mag_range` specified). You can specify "
                          f"`None` instead of `{mag}` to silence this warning."
                      )
                  if (
                      not isinstance(mag, int)
                      or not 0 <= mag < self.num_magnitude_bins
                  ):
                      raise Exception(
                          f"Magnitude of the augmentation must be an integer from "
                          f"`[0, {num_magnitude_bins - 1}]` range. "
                          f"Got `{mag}` for augmentation `{aug.name}`."
                      )
      self.sub_policies = _sub_policy_with_unique_names(sub_policies)
  
file_path: DALI/dali/python/nvidia/dali/auto_aug/core/policy.py
imports: import warnings
  from nvidia.dali.auto_aug.core._augmentation import Augmentation
  from typing import Optional, Sequence, Tuple
label_desc: Use image node_id 1 to create a new Policy object  with example: obj = Policy(name, num_magnitude_bins, sub_policies)