import torch


def norm(input, *args, **kwargs):
    """
    Returns the matrix norm or vector norm of a given tensor.

    Examples::

        >>> import torch
        >>> import treetensor.torch as ttorch
        >>> t1 = torch.randn(3, 4)
        >>> t1
        tensor([[ 0.0363, -1.7385,  1.0669,  2.6967],
                [ 0.0848,  0.2735,  0.3538,  0.2271],
                [-0.1014,  1.1351, -0.5761, -1.2671]])
        >>> ttorch.norm(t1)
        tensor(3.8638)

        >>> tt1 = ttorch.randn({
        ...     'a': (2, 3),
        ...     'b': {'x': (3, 4)},
        ... })
        >>> tt1
        <Tensor 0x7f95f684f4a8>
        ├── a --> tensor([[-0.5012,  2.0900,  0.0151],
        │                 [-0.5035,  0.2144,  0.8370]])
        └── b --> <Tensor 0x7f95f684f400>
            └── x --> tensor([[ 0.3911,  0.3557, -2.2156,  0.3653],
                              [-0.3503,  1.2182, -0.2364, -0.2854],
                              [-1.5770, -0.7349,  0.8391, -0.2845]])
        >>> ttorch.norm(tt1)
        <Tensor 0x7f95f684fa20>
        ├── a --> tensor(2.3706)
        └── b --> <Tensor 0x7f95f684f978>
            └── x --> tensor(3.2982)
    """
    return torch.norm(input, *args, **kwargs)