Repository: pytorch
Issue: Importing numpy makes Tensor min max crash
Labels: triaged,module: numpy

### 🐛 Describe the bug

`torch.Tensor.max()` and `torch.Tensor.min()` work fine when when getting the overall extremum, but as soon as I specify the axis, e.g. `torch.Tensor.max(dim=-1)`, the script crashes quietly. Importantly, there is NO error thrown. Weirdly the script works about 20% of the time and doesnt 80% of the time. Rebooting the OS doesn't work.

```python
import itertools
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import functorch as FT
import functools

# create data
torch.manual_seed(0)
TAU = 0.01
P = torch.softmax(torch.randn(10,3), dim=-1)
Y = torch.distributions.Categorical(P).sample().unsqueeze(dim=-1)

def func(f: torch.Tensor, y: torch.Tensor, tau: float) -> torch.Tensor:
    f_true = f[torch.arange(f.shape[0]), y]
    print(f.max())
    f_pred = f.max(dim=-1)
    print("NOT CRASHED :D")


c_out = func(P, Y, TAU)
print(c_out)
```

This runs well and prints `tensor(0.7848)` then crashes. The same behaviour can be observed for `torch.max` and `torch.min`.

As soon as I remove the import of `numpy` this works fine. Importing numpy after `torch` also works.

This suggests, that having numpy readily available breaks `torch.min` and `torch.max` when applied over certain dimensions.


### Versions

PyTorch version: 1.13.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.0 (x86_64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.202)
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.4 (main, Mar 31 2022, 03:38:35) [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-10.16-x86_64-i386-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.1
[pip3] pytorch-lightning==1.7.2
[pip3] torch==1.13.0
[pip3] torchaudio==0.13.0
[pip3] torchinfo==1.7.0
[pip3] torchmetrics==0.9.3
[pip3] torchvision==0.14.0
[conda] blas                      1.0                         mkl  
[conda] mkl                       2021.4.0           hecd8cb5_637  
[conda] mkl-service               2.4.0           py310hca72f7f_0  
[conda] mkl_fft                   1.3.1           py310hf879493_0  
[conda] mkl_random                1.2.2           py310hc081a56_0  
[conda] numpy                     1.23.1          py310hdcd3fac_0  
[conda] numpy-base                1.23.1          py310hfd2de13_0  
[conda] pytorch-lightning         1.7.2                    pypi_0    pypi
[conda] torch                     1.13.0                   pypi_0    pypi
[conda] torchaudio                0.13.0                   pypi_0    pypi
[conda] torchinfo                 1.7.0                    pypi_0    pypi
[conda] torchmetrics              0.9.3                    pypi_0    pypi
[conda] torchvision               0.14.0                   pypi_0    pypi


cc @mruberry @rgommers