semvec/pypi-packages huggingface dataset:
zonar-ds-logger 1.0.0
Python logger helper to log in json and redirect flask logs

zonar_ds_logger
======

Overview
------
A logger class that initializes a logger and logs in json when specified. 
It also redirects flask logs so it doesn’t always show up as ERROR

Usage
------
```python
from zonar_ds_logger.logger import logger

logger.initialize("evan-test", "info", False)
log = logger.get_logger()

log.debug("debug")
log.info("info")
log.warning("warning")
log.error("error")
```

Arguments
------
Parameters that can be passed into logger.initialize are as follows:

- name (str): Name of the logger
- log_level (str): Lowest log level to log. Default is "debug". Options are "debug", "info", "warning", "error"
- json_logging (bool): Whether to log in json or not. Options that evaluate to true are ("true", "t", "1", "y", "yes")
                     Default converts value in JSON_LOGGING env var to bool if set else True
pytorch-categorical 0.0.3
Draw a large number of samples from a categorical distribution with large support on the GPU using Pytorch.

# Fast Sampling from Categorical Distributions on the GPU using PyTorch

Currently, the `pytorch.distributions.Categorical` is a bit slow if you
need to draw a large number of samples from a static categorical distribution.
Also, you are limited to having no more than 2^24 different outcomes.

The 
["alias method"](http://cgi.cs.mcgill.ca/~enewel3/posts/alias-method/index.html)
let's you sample very quickly from distributions with large support, and this
implementation in PyTorch let's you have more than 2^24 outcomes.

I needed this for rapid generation of word embeddings in
[hilbert](https://github.com/enewe101/hilbert).

# Install

``pip install pytorch-categorical``

# Use

    import pytorch_categorical
	import torch

	num_outcomes = int(1e6)
    probs = torch.random(num_outcomes)
	probs /= probs.sum()

	sampler = pytorch_categorical.Categorical(probs)

	num_samples = int(1e6)
	samples = sampler.sample((num_samples,))

The constructor also takes a `dtype` and a `device` if you want to specify 
them.  By default

# Posterity
At the time I made this, there was an open issue to incorporate a more rapid
sampler based on the alias method, but nothing was released yet.  Hopefully
that will get into a release soon!  For now, use this!

# Tested.  It's Correct and Fast.
I've backed this by a few simple tests, including a benchmark against torch.
This implementation takes about 175X longer to construct a sampler with one
million outcomes, but after this up-front cost, it yields (draws of ten
thousand) samples about 3000X faster (with greater advantage the more samples
that are eventually drawn).  So the main usecase is when you have to draw many
samples from a stable distribution.

Run the correctness and benchmark tests: ``python test.py``.

Enjoy!