torch.onnx.export failed for models with Bernoulli operator
Labels: module: onnx, triaged

### 🐛 Describe the bug

torch.onnx.export failed for models such as **efficientnet, convnext and swin_transformer** (Bernoulli operator existing in these models).

The program crash and report the following error:
```
SymbolicValueError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
**Unsupported: ONNX export of operator Bernoulli, out parameter is not supported for bernoulli.** Please feel free to request support or submit a pull request on PyTorch GitHub: https://github.com/pytorch/pytorch/issues  [Caused by the value '822 defined in (%822 : Float(1, 1, 1, 1, strides=[1, 1, 1, 1], requires_grad=0, device=cpu) = onnx::Constant[value={0}](), scope: torchvision.models.efficientnet.EfficientNet::/torch.nn.modules.container.Sequential::features/torch.nn.modules.container.Sequential::features.1/torchvision.models.efficientnet.FusedMBConv::features.1.1/torchvision.ops.stochastic_depth.StochasticDepth::stochastic_depth # /root/anaconda3/lib/python3.9/site-packages/torchvision/ops/stochastic_depth.py:40:0
)' (type 'Tensor') in the TorchScript graph. The containing node has kind 'onnx::Constant'.] 
    (node defined in /root/anaconda3/lib/python3.9/site-packages/torchvision/ops/stochastic_depth.py(40): **stochastic_depth**
/root/anaconda3/lib/python3.9/site-packages/torchvision/ops/stochastic_depth.py(62): forward
/root/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py(1178): _slow_forward
/root/anaconda3/lib/python3.9/site-packages/torch/nn/modules/module.py(1190): _call_impl
/root/anaconda3/lib/python3.9/site-packages/torchvision/models/efficientnet.py(228): forward
...
```

I have checked the model definition of efficientnet and found that there is a call to "stochastic_depth" (torchvision.ops):

``` python
def stochastic_depth(input: Tensor, p: float, mode: str, training: bool = True) -> Tensor:
      if not torch.jit.is_scripting() and not torch.jit.is_tracing():
        _log_api_usage_once(stochastic_depth)
    if p < 0.0 or p > 1.0:
        raise ValueError(f"drop probability has to be between 0 and 1, but got {p}")
    if mode not in ["batch", "row"]:
        raise ValueError(f"mode has to be either 'batch' or 'row', but got {mode}")
    if not training or p == 0.0:
        return input

    survival_rate = 1.0 - p
    if mode == "row":
        size = [input.shape[0]] + [1] * (input.ndim - 1)
    else:
        size = [1] * input.ndim
    noise = torch.empty(size, dtype=input.dtype, device=input.device)
    noise = noise.bernoulli_(survival_rate) ############ Here
    if survival_rate > 0.0:
        noise.div_(survival_rate)
    return input * noise
```

**noise.bernoulli_(survival_rate)** seems a normal function call but failed in the following assertions (**out is not None, generator is not None**):

``` python
#torch.onnx -> symbolic_opset9.py
@_onnx_symbolic("aten::bernoulli")
@_beartype.beartype
def bernoulli(g: jit_utils.GraphContext, input, generator=None, out=None):
    if out is not None:
        symbolic_helper._unimplemented(
            "Bernoulli", "out parameter is not supported for bernoulli", input
        )
    if generator is not None and not symbolic_helper._is_none(generator):
        symbolic_helper._unimplemented(
            "Bernoulli", "generator is not supported for bernoulli", input
        )

    dtype = symbolic_helper._try_get_scalar_type(input)
    if dtype is None:
        return symbolic_helper._unimplemented(
            "Bernoulli", "input dtype not accessible", input
        )
    p = g.op(
        "RandomUniformLike",
        input,
        high_f=1.0,
        low_f=0.0,
        dtype_i=_type_utils.JitScalarType.from_name(dtype).onnx_type(),
    )
    output = g.op("Less", p, input)
    return g.op(
        "Cast", output, to_i=_type_utils.JitScalarType.from_name(dtype).onnx_type()
    )
```

I have tried to remove the following checks and it works as normal, i.e., the torch.onnx is able to export the abovementioned models.
``` python
    if out is not None:
        symbolic_helper._unimplemented(
            "Bernoulli", "out parameter is not supported for bernoulli", input
        )
    if generator is not None and not symbolic_helper._is_none(generator):
        symbolic_helper._unimplemented(
            "Bernoulli", "generator is not supported for bernoulli", input
        )
```
**Is it possible to revise the assertions to warnings? or how long can we expect to have a full implementation of aten::bernoulli in torch.onnx?**

### Versions

PyTorch version: 1.13.0
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.1 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.25.0
Libc version: glibc-2.31

Python version: 3.9.7 (default, Sep 16 2021, 13:09:58)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-4.15.0-142-generic-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3070
Nvidia driver version: 470.56.05
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.5
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   43 bits physical, 48 bits virtual
CPU(s):                          48
On-line CPU(s) list:             0-47
Thread(s) per core:              2
Core(s) per socket:              24
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model:                           49
Model name:                      AMD Ryzen Threadripper 3960X 24-Core Processor
Stepping:                        0
Frequency boost:                 enabled
CPU MHz:                         2194.729
CPU max MHz:                     3800.0000
CPU min MHz:                     2200.0000
BogoMIPS:                        7585.79
Virtualization:                  AMD-V
L1d cache:                       768 KiB
L1i cache:                       768 KiB
L2 cache:                        12 MiB
L3 cache:                        128 MiB
NUMA node0 CPU(s):               0-47
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full AMD retpoline, IBPB conditional, STIBP conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate sme ssbd ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip rdpid overflow_recov succor smca

Versions of relevant libraries:
[pip3] msgpack-numpy==0.4.8
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.19.2
[pip3] numpydoc==1.1.0
[pip3] qtorch==0.2.0
[pip3] torch==1.13.0
[pip3] torch-mlir==20220522.467
[pip3] torchaudio==0.8.1
[pip3] torchpack==0.3.1
[pip3] torchsparse==2.0.0b0
[pip3] torchsummaryX==1.3.0
[pip3] torchvision==0.14.0
[conda] blas                      1.0                         mkl    https://mirrors.ustc.edu.cn/anaconda/pkgs/free
[conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
[conda] mkl                       2021.4.0           h06a4308_640    defaults
[conda] mkl-service               2.4.0            py39h7f8727e_0    defaults
[conda] mkl_fft                   1.3.1            py39hd3c417c_0    defaults
[conda] mkl_random                1.2.2            py39h51133e4_0    defaults
[conda] msgpack-numpy             0.4.8                    pypi_0    pypi
[conda] numpy                     1.19.2                   pypi_0    pypi
[conda] numpydoc                  1.1.0              pyhd3eb1b0_1    defaults
[conda] pytorch                   1.13.0              py3.9_cpu_0    pytorch
[conda] pytorch-mutex             1.0                         cpu    pytorch
[conda] qtorch                    0.2.0                    pypi_0    pypi
[conda] torch-mlir                20220522.467             pypi_0    pypi
[conda] torchaudio                0.8.1                    pypi_0    pypi
[conda] torchpack                 0.3.1                    pypi_0    pypi
[conda] torchsparse               2.0.0b0                   dev_0    <develop>
[conda] torchsummaryx             1.3.0                    pypi_0    pypi
[conda] torchvision               0.14.0                 py39_cpu    pytorch