<commit_before># Tangent

Tangent is a new, free, and open-source Python library for automatic differentiation.

Existing libraries implement automatic differentiation by tracing a program’s execution (at runtime, like PyTorch) or by staging out a dynamic data-flow graph and then differentiating the graph (ahead-of-time, like TensorFlow). In contrast, Tangent performs ahead-of-time autodiff on the Python source code itself, and produces Python source code as its output. Tangent fills a unique location in the space of machine learning tools.

![Autodiff Tool Space](docs/toolspace.png "Autodiff Tool Space")


As a result, you can finally read your automatic derivative code just like the rest of your program. Tangent is useful to researchers and students who not only want to write their models in Python, but also read and debug automatically-generated derivative code without sacrificing speed and flexibility.

Tangent works on a large and growing subset of Python, provides extra autodiff features other Python ML libraries don’t have, has reasonable performance, and is compatible with TensorFlow and NumPy.

This project is an experimental release, and is under active development. As we continue to build Tangent, and respond to feedback from the community, there might be API changes.

## Usage

Tangent has a one-function API:
```python
import tangent
df = tangent.grad(f)
```

If you want to print out derivatives at the time Tangent generates the derivative function:

```python
import tangent
df = tangent.grad(f, verbose=1)
```

Here's Tangent in action in the IPython console.

![Live Derivatives with Tangent](docs/sct-ad-live.gif "Live Derivatives with Tangent")

## Installing and running

### Installation

The easiest way to install is by cloning the git repo. Then from the rootdirectory, use either of the methods listed below. We'll have pip and conda packages shortly.

Note: The commands below will by default install the CPU build for TensorFlow. To use the GPU build, use:

    pip install tf-nightly-gpu

#### Conda

    conda env create -f environment.yml
    conda activate tangent

#### PIP

To install Tangent and its dependencies:

    pip install -e .

To install just the requirements:
<commit_msg>Tighten the import replace rules so they don't generate false changes on the reverse path.<commit_after># Tangent

Tangent is a new, free, and open-source Python library for automatic differentiation.

Existing libraries implement automatic differentiation by tracing a program’s execution (at runtime, like PyTorch) or by staging out a dynamic data-flow graph and then differentiating the graph (ahead-of-time, like TensorFlow). In contrast, Tangent performs ahead-of-time autodiff on the Python source code itself, and produces Python source code as its output. Tangent fills a unique location in the space of machine learning tools.

![Autodiff Tool Space](docs/toolspace.png "Autodiff Tool Space")


As a result, you can finally read your automatic derivative code just like the rest of your program. Tangent is useful to researchers and students who not only want to write their models in Python, but also read and debug automatically-generated derivative code without sacrificing speed and flexibility.

Tangent works on a large and growing subset of Python, provides extra autodiff features other Python ML libraries don’t have, has reasonable performance, and is compatible with TensorFlow and NumPy.

This project is an experimental release, and is under active development. As we continue to build Tangent, and respond to feedback from the community, there might be API changes.

## Usage

Tangent has a one-function API:
```python
import tangent
df = tangent.grad(f)
```

If you want to print out derivatives at the time Tangent generates the derivative function:

```python
import tangent
df = tangent.grad(f, verbose=1)
```

Here's Tangent in action in the IPython console.

![Live Derivatives with Tangent](docs/sct-ad-live.gif "Live Derivatives with Tangent")

## Installing and running

### Installation

The easiest way to install is by cloning the git repo. Then from the root directory, use either of the methods listed below. We'll have pip and conda packages shortly.

Note: The commands below will by default install the CPU build for TensorFlow. To use the GPU build, use:

    pip install tf-nightly-gpu

#### Conda

    conda env create -f environment.yml
    conda activate tangent

#### PIP

To install Tangent and its dependencies:

    pip install -e .

To install just the requirements:

{'fraction_non_alphanumeric': 0.05267778753292362, 'fraction_numerical': 0.0004389815627743635, 'mean_word_length': 4.550548112058466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2288177', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1105, 'n_words': 647}