sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: pytorch
Issue: Tensor.nonzero tries to allocate huge amount of memory for tensors on GPU with num_elements close to INT_MAX
Labels: module: dependency bug,module: cuda,module: memory usage,triaged

## 🐛 Bug

`Tensor.nonzero` fails for gpu tensors larger than `INT_MAX`, cf. #51871 . When the tensors are slightly smaller, a CUDA out of memory exception is raised with huge amounts of memory (> 1 exabyte) being requested. 

## To Reproduce

```python-console
>> x = torch.zeros(2**31-2, device="cuda")
>>> x.nonzero()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
RuntimeError: CUDA out of memory. Tried to allocate 17179869183.98 GiB (GPU 0; 10.76 GiB total capacity; 8.00 GiB already allocated; 1.47 GiB free; 8.30 GiB reserved in total by PyTorch)
```

The problem does not happen when the tensor is slightly smaller:
```python-console
>>> x = torch.zeros(2**30, device="cuda")
>>> x.nonzero()
tensor([], device='cuda:0', size=(0, 1), dtype=torch.int64)
```

or when run on cpu
```python-console
>>> x = torch.zeros(2**31-2, device="cpu")
>>> x.nonzero()
tensor([], size=(0, 1), dtype=torch.int64)
```

## Expected behavior

Return the result, if the result fits in memory. Try to allocate less memory.

## Environment

```
Collecting environment information...
PyTorch version: 1.7.1
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3

Python version: 3.8 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: 10.1.243
GPU models and configuration: 
GPU 0: GeForce RTX 2080 Ti
GPU 1: GeForce RTX 2080 Ti
GPU 2: GeForce RTX 2080 Ti
GPU 3: GeForce RTX 2080 Ti

Nvidia driver version: 450.102.04
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip] Could not collect
[conda] Could not collect
```

## Additional context

There does not really seem to be a use case where one would encounter this issue, but not run into #51871. However, this bug might give a hint on the error source so I filed it anyway. Feel free to close it, if the other issue is sufficient.

cc @ngimel
Repository: flutter
Issue: Make it more clear that video_player doesn't support audio (even if it's accidentally supported in some platforms)
Labels: d: api docs,p: video_player,package,team-ecosystem,P2,triaged-ecosystem

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Use case

When looking for packages to play audio, it is very common (at least for me) to look for official packages as they are usually more widely used and better supported. Trying `video_player` seems to be a common pattern and since it mostly work (at least in Web and Android), some users (like me) start using it, only to eventually bump into some wall and finding out audio is not officially supported and getting a "tough luck you spent time with video_player but this won't fix".

This is a non-exhaustive list of audio-related issues I found, which suggests I'm not alone here:

* #38480
* #47105
* #75508
* #48008

There is even people answering questions and recommending to use `video_player` as an audio player in stackoverflow:

* https://stackoverflow.com/questions/59499342/how-to-play-audio-on-the-all-platforms-including-web-in-flutter

## Proposal

<!--
     Briefly but precisely describe what you would like Flutter to be able to do.

     Consider attaching images showing what you are imagining.

     Does this have to be provided by Flutter directly, or can it be provided
     by a package on pub.dev/flutter? If so, maybe consider implementing and
     publishing such a package rather than filing a bug.
-->

Just add some clear message at the top of the package [home page](https://pub.dev/packages/video_player) saying that even when audio-only playing might work incidentally, it is not officially supported and it should not be used, and ideally listing alternative package to reproduce audio (like [just_audio](https://pub.dev/packages/just_audio)). It would be also put another note in the [supported formats section](https://pub.dev/packages/video_player#supported-formats), since when you click in there you'll find audio-only formats listed as supported.
Repository: rust
Issue: Incorrect diagnostic for unstable applicable items
Labels: A-diagnostics,T-compiler,C-bug,A-suggestion-diagnostics,D-incorrect

I tried to compile this code written for Rust 1.47+ with Rust 1.46:

```rust
fn foo(range: Range<usize>) -> bool {
    range.is_empty()
}
```

And I got this error (on 1.46):

```rust
error[E0034]: multiple applicable items in scope
   --> src/lib.rs:133:18
    |
133 |         if range.is_empty() {
    |            ------^^^^^^^^--
    |            |     |
    |            |     multiple `is_empty` found
    |            help: disambiguate the associated function for candidate #2: `std::iter::ExactSizeIterator::is_empty(&range)`
    |
    = note: candidate #1 is defined in an impl for the type `std::ops::Range<Idx>`
    = note: candidate #2 is defined in an impl of the trait `std::iter::ExactSizeIterator` for the type `std::ops::Range<usize>`
```

However, when I tried to use the inherent impl with `Range::is_empty(&range)`, it still failed to compile:

```rust
error[E0034]: multiple applicable items in scope
   --> src/lib.rs:133:19
    |
133 |         if Range::is_empty(range) {
    |            -------^^^^^^^^
    |            |      |
    |            |      multiple `is_empty` found
    |            help: disambiguate the associated function for candidate #2: `std::iter::ExactSizeIterator::is_empty`
    |
    = note: candidate #1 is defined in an impl for the type `std::ops::Range<Idx>`
note: candidate #2 is defined in the trait `std::iter::ExactSizeIterator`
```

As it turns out, `Range::is_empty()` was only stabilized in 1.47.0, so it is not actually available when compiling with stable 1.46.0. `ExactSizeIterator::is_empty()` is still unstable in 1.50.0, so it's also inaccessible here. Without that context, the error message is pretty confusing. I think we can do better here!

### Meta

`rustc --version --verbose`:
```
enrai instant-segment $ rustc -vV
rustc 1.46.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.46.0
LLVM version: 10.0
```
Repository: angular
Issue: [Animations] :enter / :leave animations are triggered incorrectly for reordered items
Labels: area: animations,P4

#### Reproduction

I've created a fork of the CDK Drag&Drop custom placeholder example to demonstrate this bug:

https://stackblitz.com/edit/angular-3katn7?file=src/app/cdk-drag-drop-custom-placeholder-example.ts

Steps to reproduce:
1. Drag a list item and drop it at some list position further down below
2. Click the 'Remove' button on the dropped list item
3.  Watch the `:leave` animation being triggered correctly
4. Now click the 'Remove' button on some item that was repositioned above the dropped list item
5. Watch the `:enter` animation being triggered instead of `:leave`
 
 
#### Expected Behavior

What behavior were you expecting to see?

The `:leave` animation should be triggered correctly on any list item wether or not it has been repositioned due to drag & drop at some point in time.


#### Environment

- Angular: 11.1.1
- CDK/Material: 11.1.1
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): win32 x64
Repository: PowerToys
Issue: FancyZone Editor theming setting
Labels: Product-Settings,FancyZones-Editor,FancyZones-Settings,Product-FancyZones,Planning-Consideration

From issue #9564, we should add in theming support to the editor.
Repository: pytorch
Issue: [cuda jit extentions] global shared destination conflicts with virtual envs
Labels: oncall: jit

## 🚀 Feature
<!-- A clear and concise description of the feature proposal -->

Currently CUDA JIT extensions get all installed into `~/.cache/torch_extensions`, this doesn't work with virtual environments.

I propose that these get installed into some location under the virtual environment tree.

## Motivation

Say you test cuda-10.2 and cuda-11.0 virtual envs, and the cuda extensions is always one or the other - you have to constantly recompile the extensions when switching to a new environment which is extremely error-prone as it could lead to subtle error - if not just painful. And often I run multiple environments concurrently on the same box which renders this a huge problem.

## Pitch

<!-- A clear and concise description of what you want to happen. -->

`torch_extensions` should be placed in the python tree, perhaps under `site_packages` or similar and not in a global location visible from any python virtual environment.

Thank you.

cc @gmagogsfm
Repository: go
Issue: io/fs: add more specific documentation about valid paths
Labels: Documentation,NeedsInvestigation

<!--
Please answer these questions before submitting your issue. Thanks!
For questions please use one of our forums: https://github.com/golang/go/wiki/Questions
-->

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.16rc1 darwin/amd64
</pre>

### Does this issue reproduce with the latest release?



### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/xyz/gopath/bin"
GOCACHE="/Users/xyz/Library/Caches/go-build"
GOENV="/Users/xyz/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/xyz/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/elagergren/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/xyz/sdk/go1.16rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/xyz/sdk/go1.16rc1/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16rc1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/private/tmp/b58/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2b/74fz3jhd4wz4vnbf4z7ywzww0000gp/T/go-build3417337290=/tmp/go-build -gno-record-gcc-switches -fno-common"
</pre></details>

We are early adopters of `io/fs`: we'd been wanting to move to a VFS implementation and the original proposal gave us the push to do so. So far, it has been a good decision. It's allowed us to stub out the file system implementation for tests (`SlowFS`, `CorruptedFS`, etc.), to more easily test bugs by replaying application state from ZIP files, and to transparently encrypt files.

One pain point, however, is knowing what constitutes a valid file path for a particular `FS`. With the `os` package, we could make a reasonable set of assumptions. For example, rejecting or not creating paths with problematic or illegal characters like null bytes or rejecting or not creating excessively long paths. But with `io/fs`, we can't. It's impossible to know whether the `FS` is `os.DirFS`, a remote object store, or an in-memory file system.

There seem to be two possibly correct answers:

1. A `FS` must accept any path for which `ValidPath` returns true and therefore translate it accordingly
2. It's impossible to know and therefore the API using `io/fs` must document what it expects out of the `FS`

The implementation of `os.DirFS` seems to assume (2), but it's not clearly documented. `ValidPath` should more clearly document its assumptions.

Relates to #44166.
Repository: pytorch
Issue: Can't reassign a child module instance to a lambda
Labels: module: nn,triaged

It seems we can't assign a module's attribute to a lambda once it was a module before. This + absence of easy shortcuts for anonymous module creation (https://github.com/pytorch/pytorch/issues/51782) prevents some useful stubbing approaches with lambdas (or functions such).

```python
import torch

class Foo(torch.nn.Module):
    def __init__(self):
        super().__init__()
        # existing code
        self.inner = torch.nn.Identity() # If this line is commented, then no error 

        # stubbing (or external) code
        self.inner = lambda x: x + 1 # TypeError: cannot assign '__main__.Foo.__init__.<locals>.<lambda>' as child module 'inner' (torch.nn.Module or None expected)

if __name__ == '__main__':
    Foo()
```

cc @albanD @mruberry @jbschlosser
Repository: rust
Issue: Documentation of a re-export doesn't appear on level-two re-export
Labels: T-rustdoc,C-bug

I have a macro crate with a "peer dependency" on another crate, i.e. I can't write doctests for the macro itself without introducing circular dev-dependencies which are kind of annoying. The other crate re-exports the macro and the macro is actually expected to only ever be used through there, so I documented the re-export instead. However, there's another higher-level crate that re-exports a bunch of other crates entirely including the one that re-exports the macro. In the documentation of the higher-level crate, the documentation for the macro does not appear, while it appears on the "level-one" re-export.

Minimal reproduction:

Crate foo re-exports a type from bar, which is itself a re-export of a type from baz. The docs on each of the declarations (original type definition in `baz`, re-exports in `bar` and `foo`) are simply the crate name

```rust
// # baz/src/lib.rs
/// baz
pub struct Type;

// # bar/src/lib.rs
/// bar
pub use baz::Type;

// # foo/src/lib.rs
/// foo
pub use bar::Type;
```

Here is a repo with this: https://github.com/jplatte/rust-issue-81893

I expected to see this happen: the docs of `foo::Type` should be `foo bar baz`

Instead, this happened: the docs of `foo::Type` are `foo baz`

### Meta

Happens with latest nightly from rustup that has rustfmt:

`rustc --version --verbose`:
```
rustc 1.51.0-nightly (04caa632d 2021-01-30)
binary: rustc
commit-hash: 04caa632dd10c2bf64b69524c7f9c4c30a436877
commit-date: 2021-01-30
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1
```

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"TaKO8Ki"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->
Repository: flutter
Issue: Flutter run -d chrome terminates when MacOS sleep 
Labels: tool,a: quality,platform-web,P3,team-web,triaged-web

When MacOS goes to sleep while `flutter run -d chrome` is running, the flutter app will terminate and closes chrome. I'm not sure if this is a bug or intentional. I'm also not sure if there's a setting to change this behavior (if so please let me know). 

## Steps to Reproduce

<!-- You must include full steps to reproduce so that we can reproduce the problem. -->

1. Run `flutter run -d chrome`.
2. manually put Mac to sleep
3. wake up the device
4. Chrome will be closed and flutter run will be terminated 

**Expected results:** 
I expect the same behavior as with iOS and Android simulator where `flutter run` doesn't terminate.

**Actual results:** 
After waking up, this is the output:
```sh
[~] flutter run -v -d chrome
...
...
...
[+34213 ms] DevHandler: Stopped debug service on ws://127.0.0.1:54573

[+3981 ms] Application finished.
[   +1 ms] "flutter run" took 65,520ms.
[ +257 ms] ensureAnalyticsSent: 254ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hook priority 4
[ +587 ms] Shutdown hooks complete
[   +1 ms] exiting with code 0
```

<details>
  <summary>Flutter doctor -v</summary>

```
[✓] Flutter (Channel master, 1.26.0-18.0.pre.213, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en)
    • Flutter version 1.26.0-18.0.pre.213 at /Users/osaxma/fvm/versions/master
    • Framework revision 021311ed8a (4 hours ago), 2021-02-08 09:21:46 -0800
    • Engine revision b04955656c
    • Dart version 2.13.0 (build 2.13.0-0.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/osaxma/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.53.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.150

• No issues found!
```

</details>
Repository: transformers
Issue: Supporting truncation from both ends of the sequence in BertTokenizerFast
Labels: Feature request

# 🚀 Feature request

For `BertTokenizerFast` (inherited from `PreTrainedTokenizerFast`), it seems like `__call__` only supports truncating from the end of the sequences if we set `truncation` to be `longest_first`, `only_first` or `only_second`. For example, assuming `max_length` is 6 and `truncation` is `longest_first`:

(`I have a pen`, `I have an apple`) --> truncation --> (`I have a`, `I have an`)

However, if we take a closer look at [Google's original data-preprocessing script for BERT](https://github.com/google-research/bert/blob/master/create_pretraining_data.py#L430), truncation can happen at both ends of the sequence randomly:

(`I have a pen`, `I have an apple`) --> truncation --> (`I have a`, `have an apple`) or (`have a pen`, `I have an`) or (`I have a`, `I have an`) or (`have a pen`, `have an apple`)

For `BertTokenizer`, perhaps I could reassigned its `truncate_sequences` member function (https://github.com/huggingface/transformers/blob/master/src/transformers/tokenization_utils_base.py#L2887) with a new function that implements Google's truncation scheme; however, for `BertTokenizerFast`, truncation is handled completely in Rust, about which I can't do anything.

An alternative is to call `tokenize` first, then truncate the sequence using Google's scheme, ~~then call `__call__` and passing `is_split_into_words` as `True`~~. However, this approach has significant performance impact comparing to calling `__call__` on a batch of sequences directly (the average total tokenization latency doubled in our experiments).

> PS: Turned out `is_split_into_words` doesn't work this way (since when it sees a subword `##abc`, `__call__` would further tokenize it into `#` `#` `abc` even if `is_split_into_words==True`). Thus, the actual (but slow) alternative is to 1) call `tokenize` 2) implement the truncation scheme and making sure a subword starting with `##` won't be at the boundary 3) call `convert_tokens_to_string` 4) call `__call__`. Effectively, this alternative tokenizes the same sequence twice.

I'm wondering if's possible to add official support for random truncation from both ends of the sequence?

## Motivation

To match Google's truncation scheme exactly and minimizing artificial impacts on pretraining convergence.

## Your contribution

Unfortunately I'm not very familiar with Rust (I can read it, but I neve learned/wrote Rust before), thus I can't help much.
Repository: pytorch
Issue: torch.nn.functional.binary_cross_entropy(_with_logits) outputs NaN
Labels: module: nn,triaged,module: NaNs and Infs

## 🐛 Bug

`torch.nn.functional.binary_cross_entropy_with_logits` outputs NaN when input is empty or large
`torch.nn.functional.binary_cross_entropy` outputs NaN when input is empty


## To Reproduce
~~~python
import torch
torch.nn.functional.binary_cross_entropy(input=torch.tensor([]), target=torch.tensor([]))
~~~
Output:
~~~python
tensor(nan)
~~~

~~~python
import torch
torch.nn.functional.binary_cross_entropy_with_logits(input=torch.tensor([]), target=torch.tensor([]))
~~~
Output:
~~~python
tensor(nan)
~~~

~~~python
import torch
torch.nn.functional.binary_cross_entropy_with_logits(input=torch.tensor([-2.3135e+307,  6.6756e+307]), target=torch.ones((2)))
~~~

Output:
~~~python
tensor(nan)
~~~



## Expected behavior

Expect a grace exception message if the parameters are invalid or unexpected

## Environment
PyTorch version: 1.8.0.dev20210126+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.4 LTS (x86_64)
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect

Python version: 3.7 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
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


cc @albanD @mruberry @jbschlosser
Repository: flutter
Issue: Report the correct FPS in DevTools when it dynamically changes. 
Labels: platform-android,platform-ios,engine,c: performance,perf: speed,P2,team-engine,triaged-engine

Platforms like Android can have variable OS-wide FPS. The value can change during scroll or based on power saving settings. 

The value can be checked in the developer options under "Show refresh rate". 

We'd want to make sure that the OS's FPS setting isn't just read once at https://github.com/flutter/engine/blob/27240dd8ebfd08f3c929e8605851130dd021f156/shell/platform/android/io/flutter/view/VsyncWaiter.java#L52 but is listened to continually as @gaaclarke pointed out with https://developer.android.com/reference/android/hardware/display/DisplayManager.html#registerDisplayListener(android.hardware.display.DisplayManager.DisplayListener,%20android.os.Handler).
Repository: pytorch
Issue: torch.nn.functional.grid_sample outputs NaN
Labels: module: nn,triaged,module: NaNs and Infs

## 🐛 Bug

`torch.nn.functional.grid_sample` outputs NaN if `grid` contains large value

## To Reproduce
~~~python
import torch
torch.nn.functional.grid_sample(input=torch.ones([1,1,1,5]), grid=torch.tensor([[[[ 2.9839e+38, -3.2406e+38]]]]))
~~~

Output:
~~~python
tensor([[[[nan]]]])
~~~
## Expected behavior

Expect a grace exception message if the parameters are invalid or unexpected

## Environment
PyTorch version: 1.8.0.dev20210126+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.4 LTS (x86_64)
GCC version: Could not collect
Clang version: Could not collect
CMake version: Could not collect

Python version: 3.7 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
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

cc @albanD @mruberry @jbschlosser