import torch


def mul(input, other, *args, **kwargs):
    """
    Multiplies each element of the input ``input`` with the scalar ``other`` and
    returns a new resulting tensor.

    Examples::

        >>> import torch
        >>> import treetensor.torch as ttorch
        >>> ttorch.mul(
        ...     ttorch.tensor([1, 2, 3]),
        ...     ttorch.tensor([3, 5, 11]),
        ... )
        tensor([ 3, 10, 33])

        >>> ttorch.mul(
        ...     ttorch.tensor({
        ...         'a': [1, 2, 3],
        ...         'b': {'x': [[3, 5], [9, 12]]},
        ...     }),
        ...     ttorch.tensor({
        ...         'a': [3, 5, 11],
        ...         'b': {'x': [[31, -15], [13, 23]]},
        ...     })
        ... )
        <Tensor 0x7f11b139ca58>
        ├── a --> tensor([ 3, 10, 33])
        └── b --> <Tensor 0x7f11b139cb00>
            └── x --> tensor([[ 93, -75],
                              [117, 276]])
    """
    return torch.mul(input, other, *args, **kwargs)