code: def apply_auto_augment(
      policy: Policy,
      data: _DataNode,
      seed: Optional[int] = None,
      **kwargs,
  ) -> _DataNode:
      """
      Applies AutoAugment (https://arxiv.org/abs/1805.09501) augmentation scheme to the
      provided batch of samples.
  
      Args
      ----
      policy: Policy
          Set of sequences of augmentations to be applied in AutoAugment fashion.
      data : DataNode
          A batch of samples to be processed.
      seed: int, optional
          Seed to be used to randomly sample operations (and to negate magnitudes).
      kwargs:
          A dictionary of extra parameters to be passed when calling augmentations.
          The signature of each augmentation is checked for any extra arguments and if
          the name of the argument matches one from the `kwargs`, the value is
          passed as an argument. For example, some augmentations from the default
          AutoAugment suite accept ``shape``, ``fill_value`` and ``interp_type``.
  
      Returns
      -------
      DataNode
          A batch of transformed samples.
      """
      if len(policy.sub_policies) == 0:
          raise Exception(
              f"Cannot run empty policy. Got {policy} in `apply_auto_augment` call."
          )
      max_policy_len = max(
          len(sub_policy) for sub_policy in policy.sub_policies
      )
      should_run = fn.random.uniform(
          range=[0, 1],
          shape=(max_policy_len,),
          dtype=types.FLOAT,
          seed=seed,
      )
      sub_policy_id = fn.random.uniform(
          values=list(range(len(policy.sub_policies))),
          seed=seed,
          dtype=types.INT32,
      )
      run_probabilities = _sub_policy_to_probability_map(policy)[
          sub_policy_id
      ]
      magnitude_bins = _sub_policy_to_magnitude_bin_map(policy)[
          sub_policy_id
      ]
      aug_ids, augmentations = _sub_policy_to_augmentation_map(policy)
      aug_ids = aug_ids[sub_policy_id]
      if any(
          aug.randomly_negate for aug in policy.augmentations.values()
      ):
          magnitude_bins = signed_bin(
              magnitude_bins, seed=seed, shape=(max_policy_len,)
          )
      _forbid_unused_kwargs(
          policy.augmentations.values(), kwargs, "apply_auto_augment"
      )
      for stage_id in range(max_policy_len):
          if should_run[stage_id] < run_probabilities[stage_id]:
              op_kwargs = dict(
                  data=data,
                  magnitude_bin=magnitude_bins[stage_id],
                  num_magnitude_bins=policy.num_magnitude_bins,
                  **kwargs,
              )
              data = _pretty_select(
                  augmentations[stage_id],
                  aug_ids[stage_id],
                  op_kwargs,
                  auto_aug_name="apply_auto_augment",
                  ref_suite_name="get_image_net_policy",
              )
      return data
  
file_path: DALI/dali/python/nvidia/dali/auto_aug/auto_augment.py
imports: from typing import List, Optional, Tuple, Union
  from nvidia.dali import fn
  from nvidia.dali import types
  from nvidia.dali.auto_aug import augmentations
  from nvidia.dali.auto_aug.core import _Augmentation, Policy, signed_bin
  from nvidia.dali.auto_aug.core._args import forbid_unused_kwargs
  from nvidia.dali.auto_aug.core._utils import get_translations, pretty_select
  from nvidia.dali.data_node import DataNode
label_desc: Use image node_id 3 for calling a global function with example usage: apply_auto_augment(policy, data, seed) and returns: data