code: def apply_mixing_transforms(
      opts: argparse.Namespace, data: Dict
  ) -> Dict:
      """
      Helper function to apply MixUp/CutMix transforms. If both MixUp and CutMix transforms
      are selected with 0.0 < p <= 1.0, then one of them is chosen randomly and applied.
  
      Input data format:
          data: mapping of: {
              "samples": {"sample_key": Tensor of shape: [Batch, Channels, Height, Width]},
              "targets": {"target_key": IntTensor of shape: [Batch]}
          }
  
          OR
          data: mapping of: {
              "samples": {"sample_key": Tensor of shape: [Batch, Channels, Height, Width},
              "targets": IntTensor of shape: [Batch]
          }
  
          OR
          data: mapping of: {
              "samples": Tensor of shape: [Batch, Channels, Height, Width],
              "targets": {"target_key": IntTensor of shape: [Batch]}
          }
          OR
          data: mapping of: {
              "samples": Tensor of shape: [Batch, Channels, Height, Width],
              "targets": IntTensor of shape: [Batch]
          }
      Output data format: Same as the input
      """
  
      mixup_transforms = []
      if getattr(opts, "image_augmentation.mixup.enable"):
          n_classes = getattr(opts, "model.classification.n_classes")
          if n_classes is None:
              logger.error(
                  "Please specify number of classes. Got None."
              )
          mixup_transforms.append(
              RandomMixup(opts=opts, num_classes=n_classes)
          )
  
      if getattr(opts, "image_augmentation.cutmix.enable"):
          n_classes = getattr(opts, "model.classification.n_classes")
          if n_classes is None:
              logger.error(
                  "Please specify number of classes. Got None."
              )
          mixup_transforms.append(
              RandomCutmix(opts=opts, num_classes=n_classes)
          )
  
      if len(mixup_transforms) > 0:
          _mixup_transform = random.choice(mixup_transforms)
          data = _mixup_transform(data)
      return data
  
imports: import argparse
  import math
  import random
  from typing import Dict, Tuple
  import torch
  from torch import Tensor
  from torch.nn import functional
  from torchvision.transforms import functional
  from data.transforms import TRANSFORMATIONS_REGISTRY, BaseTransformation
  from utils import logger
label_desc: Use image node_id 1 for calling a global function with example usage: apply_mixing_transforms(opts, data) and returns: data