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",")"]
docstr: Args:
      sample: the batch data.
docstr_tok: ["Args",":","sample",":","the","batch","data","."]
code: def __call__(self, sample: Dict[str, Any]) -> Dict[str, Any]:
      """
      Args:
          sample: the batch data.
      """
      if sample["target"].ndim == 1:
          assert (
              self.num_classes is not None
          ), "num_classes is expected for 1D target"
          sample["target"] = convert_to_one_hot(
              sample["target"].view(-1, 1), self.num_classes
          )
      else:
          assert (
              sample["target"].ndim == 2
          ), "target tensor shape must be 1D or 2D"
  
      c = (
          Beta(self.alpha, self.alpha)
          .sample()
          .to(device=sample["target"].device)
      )
      permuted_indices = torch.randperm(sample["target"].shape[0])
  
      sample["target"] = (
          c * sample["target"]
          + (1.0 - c) * sample["target"][permuted_indices, :]
      )
      sample["input"] = _recursive_mixup(
          sample["input"], permuted_indices, c
      )
  
      return sample
  
imports: import collections.abc
  from typing import Any, Dict, Optional
  import numpy
  import torch
  from classy_vision.generic.util import convert_to_one_hot
  from torch.distributions.beta import Beta
  from vissl.data.collators import register_collator
  from .moco_collator import moco_collator
  from .simclr_collator import simclr_collator
label_desc: Use image node_id 2 for calling the MixupTransform obj's underlying member method code with example usage: obj.__call__(sample) and returns: sample