import torch


def pow(input, exponent, *args, **kwargs):
    """
    Takes the power of each element in ``input`` with ``exponent`` and
    returns a tensor with the result.

    Examples::

        >>> import torch
        >>> import treetensor.torch as ttorch
        >>> ttorch.pow(
        ...     ttorch.tensor([4, 3, 2, 6, 2]),
        ...     ttorch.tensor([4, 2, 6, 4, 3]),
        ... )
        tensor([ 256,    9,   64, 1296,    8])

        >>> ttorch.pow(
        ...     ttorch.tensor({
        ...         'a': [4, 3, 2, 6, 2],
        ...         'b': {
        ...             'x': [[3, 4, 6],
        ...                   [6, 3, 5]],
        ...             'y': [[[3, 5, 5],
        ...                    [5, 7, 6]],
        ...                   [[4, 6, 5],
        ...                    [7, 2, 7]]],
        ...         },
        ...     }),
        ...     ttorch.tensor({
        ...         'a': [4, 2, 6, 4, 3],
        ...         'b': {
        ...             'x': [[7, 4, 6],
        ...                   [5, 2, 6]],
        ...             'y': [[[7, 2, 2],
        ...                    [2, 3, 2]],
        ...                   [[5, 2, 6],
        ...                    [7, 3, 4]]],
        ...         },
        ...     }),
        ... )
        <Tensor 0x7f11b13b6e48>
        ├── a --> tensor([ 256,    9,   64, 1296,    8])
        └── b --> <Tensor 0x7f11b13b6d68>
            ├── x --> tensor([[ 2187,   256, 46656],
            │                 [ 7776,     9, 15625]])
            └── y --> tensor([[[  2187,     25,     25],
                               [    25,    343,     36]],

                              [[  1024,     36,  15625],
                               [823543,      8,   2401]]])
    """
    return torch.pow(input, exponent, *args, **kwargs)