def METHOD_NAME(self, x, lam):
    if lam is None:
        lam, use_cutmix = self._params_per_batch()
    else:
        _, use_cutmix = self._params_per_batch()
    if lam == 1.0:
        return 1.0
    if use_cutmix:
        (yl, yh, xl, xh), lam = cutmix_bbox_and_lam(
            x.shape, lam, ratio_minmax=self.cutmix_minmax, correct_lam=self.correct_lam
        )
        x[:, :, yl:yh, xl:xh] = x.flip(0)[:, :, yl:yh, xl:xh]
    else:
        x_flipped = x.flip(0).mul_(1.0 - lam)
        x.mul_(lam).add_(x_flipped)
    return lam