import torch


def log2(input, *args, **kwargs):
    """
    Returns a new tensor with the logarithm to the base 2 of the elements of ``input``.

    Examples::

        >>> import torch
        >>> import treetensor.torch as ttorch
        >>> ttorch.log2(ttorch.tensor([-4.0, -1.0, 0, 2.0, 4.8, 8.0]))
        tensor([   nan,    nan,   -inf, 1.0000, 2.2630, 3.0000])

        >>> ttorch.log2(ttorch.tensor({
        ...     'a': [-4.0, -1.0, 0, 2.0, 4.8, 8.0],
        ...     'b': {'x': [[-2.0, 1.2, 0.25],
        ...                 [16.0, 3.75, -2.34]]},
        ... }))
        <Tensor 0x7ff90a4cff70>
        ├── a --> tensor([   nan,    nan,   -inf, 1.0000, 2.2630, 3.0000])
        └── b --> <Tensor 0x7ff90a4bc070>
            └── x --> tensor([[    nan,  0.2630, -2.0000],
                              [ 4.0000,  1.9069,     nan]])
    """
    return torch.log2(input, *args, **kwargs)