class_docstr: This implements the mixup data augmentation in the paper
  "mixup: Beyond Empirical Risk Minimization" (https://arxiv.org/abs/1710.09412)
class_docstr_tok: ["This","implements","the","mixup","data","augmentation","in","the","paper","''","mixup",":","Beyond","Empirical","Risk","Minimization","''","(","https",":","\/\/arxiv.org\/abs\/1710.09412",")"]
code: def _params_per_elem(self, batch_size):
      lam = torch.ones(batch_size)
      use_cutmix = torch.zeros(batch_size, dtype=torch.bool)
  
      if self.mixup_alpha > 0.0 and self.cutmix_alpha > 0.0:
          use_cutmix = torch.rand(batch_size) < self.switch_prob
          lam_mix = torch.where(
              use_cutmix,
              Beta(self.cutmix_alpha, self.cutmix_alpha).sample(
                  (batch_size,)
              ),
              Beta(self.mixup_alpha, self.mixup_alpha).sample(
                  (batch_size,)
              ),
          )
      elif self.mixup_alpha > 0.0:
          lam_mix = Beta(self.mixup_alpha, self.mixup_alpha).sample(
              (batch_size,)
          )
      elif self.cutmix_alpha > 0.0:
          use_cutmix = torch.ones(batch_size, dtype=torch.bool)
          lam_mix = Beta(self.cutmix_alpha, self.cutmix_alpha).sample(
              (batch_size,)
          )
      else:
          raise ValueError(
              "One of mixup_alpha > 0., cutmix_alpha > 0., cutmix_minmax not None should be true."
          )
  
      lam = torch.where(
          torch.rand(batch_size) < self.mix_prob, lam_mix, lam
      )
      return lam, use_cutmix
  
imports: import collections.abc
  import math
  from typing import Any, Dict, Optional, Tuple
  import numpy
  import torch
  from torch.distributions.beta import Beta
label_desc: Use image node_id 2 for calling the MixupTransform obj's underlying member method code with example usage: obj._params_per_elem(batch_size) and returns: lam,  use_cutmix