mteb/LocBenchRR huggingface dataset:
jnp.select should use jax.lax.select_n
### Description

jnp.select is a function that's like jnp.where, but selects between n different arrays. jnp.where is a wrapper around jax.lax.select, which makes it more flexible in terms of input shapes and dtypes.

jax.lax.select_n (added in #9482 ) is a generalization of jax.lax.select to pick from n arrays rather than 2; it translates at lower time into a binary tree of jax.lax.select's, which is helpful for efficiency when there are many branches. jnp.select doesn't use this: it linearly chains jnp.where's across the different arrays. It would likely help performance if it did, particularly in the case where the condlist entries have lower ndim than the choicelist.

### System info (python version, jaxlib version, accelerator, etc.)

jax:    0.4.27
jaxlib: 0.4.27
numpy:  1.26.3
python: 3.11.8 (stable, redacted, redacted) [Clang google3-trunk (3b5e7c83a6e226d5bd7ed2e9b67449b64812074c)]
jax.devices (16 total, 16 local): [TpuDevice(id=0, process_index=0, coords=(0,0,0), core_on_chip=0) TpuDevice(id=1, process_index=0, coords=(0,0,0), core_on_chip=1) ... TpuDevice(id=14, process_index=0, coords=(3,1,0), core_on_chip=0) TpuDevice(id=15, process_index=0, coords=(3,1,0), core_on_chip=1)]
process_count: 1
platform: uname_result(system='Linux', node='ebe6e776479e64ea-65d7388ae36.borgtask.google.com', release='5.10.0-smp-1101.33.0.0', version='#1 [v5.10.0-1101.33.0.0] SMP @1708585970', machine='x86_64')
Add `Kernel` attribute getter/setter
Need a nice way to get/set `CUfunction_attribute`. Make them maybe nice Python properties, instead of using the C enumerator names literally.

To check:
- For attributes that can be set either through launch config (ex: #204) or kernel attribute, what's the right way to go?
When enabling EDU support for appservices, synapse will start from stream position 0 when fetching presence/receipts
Which is very expensive if you were say, matrix.org. If the appservice hasn't got a stream position in the database, we should go from a reasonable point in time.
Privilege escalation issue in the Rucio WebUI
Motivation
----------
The move to FLASK as a webui backend introduced a cookie leak in the auth_token workflows of the webui. This potentially leak the contents of cookies to other sessions. Impact is that Rucio authentication tokens are leaked to other users accessing the webui within a close timeframe, thus allowing users accessing the webui with the leaked authentication token. Privileges are therefore also escalated. 

Modification
------------
The underlying issue is that one of the cooke variables is defined as global, thus leaking within the wsgi_container in sessions executed in close time. A fix is currently in preparation.

Related issue is #4810 
Privilege escalation issue in the Rucio WebUI
Motivation
----------
The move to FLASK as a webui backend introduced a cookie leak in the auth_token workflows of the webui. This potentially leak the contents of cookies to other sessions. Impact is that Rucio authentication tokens are leaked to other users accessing the webui within a close timeframe, thus allowing users accessing the webui with the leaked authentication token. Privileges are therefore also escalated. 

Modification
------------
The underlying issue is that one of the cooke variables is defined as global, thus leaking within the wsgi_container in sessions executed in close time. A fix is currently in preparation.

Related issue is #4810
ENH: add a SequenceCollection.count_ambiguous_per_seq method
This is really valuable for identifying low quality sequences. It should also be added to the `drop_bad_seqs()` method.

This should be implemented with `cogent3.core.new_sequence.Sequence.count_ambiguous()` and `cogent3.core.new_alignment.SequenceCollection.count_ambiguous_per_seq()`
Refactor logging to be more clear and performant
After the changes in #146 in the logger to get #147 resolved, our logging process has slightly slowed down due to use of `msgpec.structs.asdict()` instead of `msgspec.to_builtins()`. We can still keep up with the IMU process, but the margin has reduced. 

I propose the following optimizations:

1. Make `LoggerDataPacket` a msgspec Struct again. Cost of initializing a new Struct is much cheaper than converting existing ones to a dict anyway.
2. The main process shouldn't be making the LoggerDataPacket into a dict, we can send it to the Logger process as a struct, and take advantage of the de/encoder now.

Rejected idea:
1. We technically don't need to attach `Context` and `Servo` packets to every LoggerDataPacket, as that just increases the amount of bytes we need to transfer to the other process. But separating that from `LoggerDataPacket` is a bit too unclean, confusing, and increases development time.
Reduce redundancy in floating type checks for Array API support
### Describe the workflow you want to enable

While working on #29978, we noticed that the following procedure is repeated across most regression metrics in `_regression.py` for the Array API:

```python
    xp, _ = get_namespace(y_true, y_pred, sample_weight, multioutput)
    dtype = _find_matching_floating_dtype(y_true, y_pred, xp=xp)

    _, y_true, y_pred, multioutput = _check_reg_targets(
        y_true, y_pred, multioutput, dtype=dtype, xp=xp
    )
```

To reduce redundancy, it would make sense to incorporate the `_find_matching_floating_dtype` logic directly into the `_check_reg_targets` function. This would result in the following cleaner implementation:

```python
    xp, _ = get_namespace(y_true, y_pred, sample_weight, multioutput)
    _, y_true, y_pred, multioutput, dtype = _check_reg_targets(
        y_true, y_pred, multioutput, xp=xp
    )
```

### Describe your proposed solution

We could introduce a new function, `_check_reg_targets_and_dtype`, defined in the obvious way. This approach would enable us to utilise the existing tests in `test_regression.py` with minimal changes.

### Describe alternatives you've considered, if relevant

We could modify the original `_check_reg_targets` function, but this would require carefully reviewing and updating the relevant tests in `test_regression.py` to ensure everything remains consistent.

### Additional context

This is part of the Array API project #26024.

ping: @ogrisel
cc: @glemaitre, @betatim, @adrinjalali.
About the FormSet class name generated through the formset_factory.
Description
	 
When you define Django Form, what format do you usually name it?
In my case, I usually name it "xxxForm".
The names of the forms used as examples in official documents related to Django Form are the same as my name define format.
# Working with forms docs.
class ContactForm(forms.Form):
	subject = forms.CharField(max_length=100)
	message = forms.CharField(widget=forms.Textarea)
	sender = forms.EmailField()
	cc_myself = forms.BooleanField(required=False)
# Working with forms docs.
class ArticleForm(forms.Form):
	title = forms.CharField()
	pub_date = forms.DateField()
# FormField docs.
class CommentForm(forms.Form):
	name = forms.CharField()
	url = forms.URLField()
	comment = forms.CharField()
The way django people name it may be based on the developers' tendencies or tastes, but I think most of them are built in the format as xxxForm.
The FormSet class I created by passing xxxForm name format to the formset_factory is named as follows.
>>> ArticleFormSet = formset_factory(ArticleForm)
>>> ArticleFormSet.__name__
'ArticleFormFormSet'
The name of the FormSet class created through the formset_factory in the form xxxForm name format is a little strange.
This is because when formset_factory creates a class through type, it adds a static "FormSet" to the form name.
def formset_factory(
	form,
	formset=BaseFormSet,
	extra=1,
	can_order=False,
	can_delete=False,
	max_num=None,
	validate_max=False,
	min_num=None,
	validate_min=False,
	absolute_max=None,
	can_delete_extra=True,
	renderer=None,
):
	...
	return type(form.__name__ + "FormSet", (formset,), attrs)
I wonder if the format of these names is intended :)
Overly permissive file permissions in `luigi/lock.py`
Hi,

I am reporting a potential security with overly permissive file permissions in

https://github.com/spotify/luigi/blob/master/luigi/lock.py#L103

When creating a file, POSIX systems allow permissions to be specified for the owner, group, and others separately. Permissions should be kept as strict as possible, preventing other users from accessing the file's contents. Additionally, they can be used to write and execute malicious code for privileged escalation.

## References
- Wikipedia: [File system permissions](https://en.wikipedia.org/wiki/File_system_permissions)
- Common Weakness Enumeration: [CWE-732](https://cwe.mitre.org/data/definitions/732.html)
rewrite(abs) should call rewrite(Abs)
```py
>>> sign(x).rewrite(abs)
sign(x)
>>> sign(x).rewrite(Abs)
Piecewise((0, Eq(x, 0)), (x/Abs(x), True))
```

This is because `rewrite(x)` just dispatches to the method called `_eval_rewrite_as_x`, and the method here is called `_eval_rewrite_as_Abs` since `Abs` is the name of the class. But most people use `abs`, the built-in function which dispatches to `Abs`. So it should be special-cased in rewrite to call `Abs`.
Provide a way to protect the boot endpoint
### Feature request description/rationale

I suggest there should be a way to protect the boot endpoint with some simple authentication. In my opinion, this is convenient even if the boot port is not exposed publicly on the internet. It would also make it easier for people to spin up a KERIA instance publicly without having to worry about unauthorized people booting agents.

# Suggestion

Implement a [Basic authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication) check by configuring the keria boot endpoint with a `username` and a `password`. Like this:

```
keria start --boot-username username --boot-password password --boot 3903
```

Or, using environment variables

```
export KERIA_BOOT_USERNAME=username
export KERIA_BOOT_PASSWORD=password
keria start --boot 3903
```

To boot an agent, you can then either:

- Use basic auth in the Boot URL: `http://username:password@localhost:3903/boot`, most http clients will set the authorization header for you.
- Set the Authorization header in the boot request manually to `Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=`

We can also add a flag to completely disable the boot endpoint (https://github.com/WebOfTrust/keria/issues/203). E.g.

```
keria start --no-boot-endpoint
```

Or, 

```
export KERIA_DISABLE_BOOT_ENDPOINT=1
```

# Considerations

There are probably much more sophisticated ways to protect the boot endpoint. Please share your thoughts. In my opinion, this could be sufficient and will allow users to more easily deploy keria instances on the internet for testing purposes.

I have code and unit tests for this, so I can open a PR if we can agree this is a good idea.
master crash with different version worker
### Prerequisites

- [X] I am using [the latest version of Locust](https://github.com/locustio/locust/releases/)
- [X] I am reporting a bug, not asking a question

### Description

I ran distributed locust with master node locust version 2.32.2 and some worker node locust version 2.25.0 (python3.8 default version).
The master node crash with the following message
```
➜  load-test locust -f locust.py --master
[2024-11-09 14:41:07,519] nasa33/INFO/locust.main: Starting Locust 2.32.2
[2024-11-09 14:41:07,524] nasa33/INFO/locust.main: Starting web interface at http://0.0.0.0:8089
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/home/uniform64/.local/lib/python3.10/site-packages/locust/runners.py", line 1030, in client_listener
    if msg.data["version"][0:4] == __version__[0:4]:
TypeError: 'NoneType' object is not subscriptable
2024-11-09T06:41:13Z <Greenlet at 0x7f254a980cc0: <bound method MasterRunner.client_listener of <locust.runners.MasterRunner object at 0x7f254a963100>>> failed with TypeError

[2024-11-09 14:41:13,652] nasa33/CRITICAL/locust.runners: Unhandled exception in greenlet: <Greenlet at 0x7f254a980cc0: <bound method MasterRunner.client_listener of <locust.runners.MasterRunner object at 0x7f254a963100>>>
Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 906, in gevent._gevent_cgreenlet.Greenlet.run
  File "/home/uniform64/.local/lib/python3.10/site-packages/locust/runners.py", line 1030, in client_listener
    if msg.data["version"][0:4] == __version__[0:4]:
TypeError: 'NoneType' object is not subscriptable
```
when I use the following command on worker node.
```
~/.local/bin/locust -f - --worker --master-host 172.16.0.33 --processes -1
```

### Command line

locust -f locust.py --master

### Locustfile contents

```python3
import random
import string
from locust import HttpUser, task


def generate_random_string(length):
    return "".join(random.choices(string.ascii_lowercase+string.digits,
                                  k=length))


def generate_random_bytes(length):
    return random.randbytes(length)


class SimpleClient(HttpUser):
    @task
    def upload(self):
        # random generate a index and some data (both string)
        index = generate_random_string(random.randint(10, 20))
        data = generate_random_bytes(random.randint(100, 200))
        self.client.post("/upload", headers={"Index": index}, data=data)
```


### Python version

3.10

### Locust version

2.32.2

### Operating system

ubuntu22.04
Crash in `--pretty` mode with `--shadow-file` which shadows a shorter file
**Crash Report**

`--pretty` inserts source file fragments from the file that's being reported. If `--shadow-file` uses a `SHADOW_FILE` which is longer than `SOURCE_FILE`, mypy crashes as it tries to access a line which doesn't exist.

**To Reproduce & Traceback**

`a.py`
```python
b: bytes  # Ensure there is at most 1 newline character in this file
```
`b.py`
```python
a: int = ""
b: bytes = 1
```
```shell
$ mypy a.py --pretty --shadow-file a.py b.py
Traceback (most recent call last):
  ...
  File "<virtual environment>\lib\site-packages\mypy\__main__.py", line 15, in console_entry
    main()
  File "mypy\main.py", line 103, in main
  File "mypy\main.py", line 187, in run_build
  File "mypy\build.py", line 193, in build
  File "mypy\build.py", line 268, in _build
  File "mypy\build.py", line 2950, in dispatch
  File "mypy\build.py", line 3348, in process_graph
  File "mypy\build.py", line 3471, in process_stale_scc
  File "mypy\errors.py", line 923, in file_messages
  File "mypy\errors.py", line 883, in format_messages
IndexError: list index out of range
```

https://github.com/python/mypy/blob/1a2c8e2a4df21532e4952191cad74ae50083f4ad/mypy/errors.py#L883

I think the solution is to insert source file fragments from `SHADOW_FILE` rather than `SOURCE_FILE`. Even if this doesn't crash, the resultant messages don't make sense. For example, inserting extra newlines into `a.py` prevents the crash but you get
```shell
a.py:1:10:1:11: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
    b: bytes
            ^
a.py:2:12:2:12: error: Incompatible types in assignment (expression has type "int", variable has type "bytes")  [assignment]
    
       ^
```

**Your Environment**

- Mypy version used: 1.11.2
- Mypy command-line flags: `--pretty --shadow-file`
- Mypy configuration options from `mypy.ini` (and other config files): None
- Python version used: 3.9
- Operating system and version: Windows 11 Home
Statevector._expectation_value_pauli returns incorrect result in certain cases
The calculation for the expectation value of the __identity operator__ seems incorrect when the statevector is __not normalized__ to 1.

I think the reason is that one should use the norm squared rather than the norm in the following lines.
https://github.com/Qiskit/qiskit/blob/1be2c5aa103f1991f2fdc75a77a09f82635b8431/qiskit/quantum_info/states/statevector.py#L478-L479

---

The whole function is attached below to provide context.

https://github.com/Qiskit/qiskit/blob/1be2c5aa103f1991f2fdc75a77a09f82635b8431/qiskit/quantum_info/states/statevector.py#L458-L491
Security: allowed origins should not be * by default
CORS headers should be restricted to the current domain at least, by default.
DOC: stats.pearsonr: incorrect `versionadded` for `axis` param
### Issue with current documentation:

Regarding the documentation of function scipy.stats.pearsonr. Typo in the version reference. The axis option is not in v1.13.0. It first appears in v1.14.0

### Idea or request for content:

Correct the version reference in the docstring. 1.13.0 --> 1.14.0

### Additional context (e.g. screenshots, GIFs)

```
def pearsonr(x, y, *, alternative='two-sided', method=None, axis=0):
    r"""
    Pearson correlation coefficient and p-value for testing non-correlation.

    The Pearson correlation coefficient [1]_ measures the linear relationship
    between two datasets. Like other correlation
    coefficients, this one varies between -1 and +1 with 0 implying no
    correlation. Correlations of -1 or +1 imply an exact linear relationship.
    Positive correlations imply that as x increases, so does y. Negative
    correlations imply that as x increases, y decreases.

    This function also performs a test of the null hypothesis that the
    distributions underlying the samples are uncorrelated and normally
    distributed. (See Kowalski [3]_
    for a discussion of the effects of non-normality of the input on the
    distribution of the correlation coefficient.)
    The p-value roughly indicates the probability of an uncorrelated system
    producing datasets that have a Pearson correlation at least as extreme
    as the one computed from these datasets.

    Parameters
    ----------
    x : array_like
        Input array.
    y : array_like
        Input array.
    axis : int or None, default
        Axis along which to perform the calculation. Default is 0.
        If None, ravel both arrays before performing the calculation.

        .. versionadded:: 1.13.0
```
[BUG - STABLE DIFFUSION 3] Grey images generated
### Describe the bug

I'm running the SD3 model [stabilityai/stable-diffusion-3-medium](https://huggingface.co/stabilityai/stable-diffusion-3-medium) with the following settings:
- Height: 1024
- Width: 1024
- Inference steps: 50
- Guidance scale: 7
- Prompts length: 32 (using the same input prompt: "A men jumps from a high building")

The model generates 32 images, but half of them are grey.

### Reproduction

Reproduction code:

```
import os

os.environ['CUDA_VISIBLE_DEVICES'] = '7'

import torch
from diffusers import StableDiffusion3Pipeline

base_dir = os.path.join(os.path.dirname(__file__), '..', '..')

def run():
    input_prompts = ["A men jumps from a high building"] * 32
    img_save_dir = f'{base_dir}/data/test_generated_img'
    os.makedirs(f'{img_save_dir}', exist_ok=True)

    pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16, cache_dir="/data0/tien/cache")
    pipe.to("cuda")

    torch.set_grad_enabled(False)
    images = pipe(
        prompt=input_prompts,
        negative_prompt="",
        height=1024,
        width=1024,
        num_inference_steps=50,
        guidance_scale=7.0
    ).images

    for j in range(len(input_prompts)):
        images[j].save(os.path.join(f'{img_save_dir}', f'{j}.jpg'))

    torch.cuda.empty_cache()
    
run()
```

### Logs

_No response_

### System Info
- Device: H100
- Driver Version: 550.127.05
- CUDA Version: 12.4
- Torch: 2.5.1+cu124
- OS: Ubuntu 22.04.3 LTS
- Python: 3.10.15
- diffusers: 0.31.0

### Who can help?

_No response_
Email parsing slowdown on edgecases
### Initial Checks

- [X] I confirm that I'm using Pydantic V2

### Description

I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `<        ` (+many spaces). 

POC below shows it. You can run it  with command like `/usr/bin/time python pydantic-poc.py 500`.
The third value in a line should be near constant which shows that approximate complexity of one operation is ~ O(N^3)

I believe it is not a security issue because it runs fast enough even for largest possible sequences however.

### Example Code

```Python
import sys

from pydantic import BaseModel, EmailStr, ValidationError
import time


class TestModel(BaseModel):
    email: EmailStr


def main(max_ind: int):
    for ind in range(1, max_ind):
        begin_at = time.time()
        try:
            TestModel.parse_obj({"email": "<" + " " * ind})
        except ValidationError:
            pass
        delta = time.time() - begin_at
        print(
            f"{ind} takes: {delta:0.6f}, delta**1/3 / ind is {delta**(1/3) / ind:0.6f}"
        )
    return


if __name__ == "__main__":
    main(int(sys.argv[1]))
```


### Python, Pydantic & OS Version

```Text
pydantic version: 2.9.2
        pydantic-core version: 2.23.4
          pydantic-core build: profile=release pgo=false
                 install path: /home/alex/Projects/re-conference/venv/lib/python3.12/site-packages/pydantic
               python version: 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0]
                     platform: Linux-6.8.0-45-generic-x86_64-with-glibc2.39
             related packages: typing_extensions-4.12.2
                       commit: unknown
```
Exporting any domain report (full metadata, current-full, -federal) takes a long time, 401s, and only generates on the second attempt
### Current Behavior

See title.

### Expected Behavior

Generating one of these reports shouldn't take multiple minutes, throw an error, or require a retry.

### Steps to Reproduce

1. In the domains table on manage.get.gov/admin, click on "Export all domain metadata", "Export current-full.csv". or "Export current-federal.csv" 
2. Wait ~3 mins for the browser to throw ERR_TOO_MANY_REDIRECTS, redirect to a 401 page
3. Navigate back to the page to re-request the report, which should arrive in roughly a minute

### Environment

Stable

### Additional Context

* The [current-full.csv I was able to retrieve](https://docs.google.com/spreadsheets/d/1STyDpPj3kx1kJFJ9gQgmLe9OUamNNs1h7c_n71Q3x_s/edit#gid=787357430) the second time. Much of the data is off.
* See [Slack thread](https://cisa-corp.slack.com/archives/C05BGB4L5NF/p1702609627618349).

### Issue Links

_No response_
In NoiseSensitivity, the `.` should be deleted as the split condition.
[ ] I checked the [documentation](https://docs.ragas.io/) and related resources and couldn't find an answer to my question.

**Your Question**
After the sentence is split, i think the `.` should no longer be used as a split condition. Many other languages ​​do not use `.` as a split condition. Just follow the result of `sentence_segmenter`.

**Code Examples**
https://github.com/explodinggradients/ragas/blob/main/src/ragas/metrics/_noise_sensitivity.py#L104C13-L104C46

**Additional context**
I will provide a pr.