import torch


def abs(input, *args, **kwargs):
    """
    Computes the absolute value of each element in ``input``.

    Examples::

        >>> import torch
        >>> import treetensor.torch as ttorch
        >>> ttorch.abs(ttorch.tensor([12, 0, -3]))
        tensor([12,  0,  3])

        >>> ttorch.abs(ttorch.tensor({
        ...     'a': [12, 0, -3],
        ...     'b': {'x': [[-3, 1], [0, -2]]},
        ... }))
        <Tensor 0x7f1c81d78ee0>
        ├── a --> tensor([12,  0,  3])
        └── b --> <Tensor 0x7f1c81d78d90>
            └── x --> tensor([[3, 1],
                              [0, 2]])
    """
    return torch.abs(input, *args, **kwargs)