import torch


def isclose(input, other, *args, **kwargs):
    """
    Returns a new tensor with boolean elements representing
    if each element of ``input`` is “close” to the corresponding element of ``other``.

    Examples::

        >>> import torch
        >>> import treetensor.torch as ttorch
        >>> import math
        >>> ttorch.isclose(
        ...     ttorch.tensor((1., 2, 3)),
        ...     ttorch.tensor((1 + 1e-10, 3, 4))
        ... )
        tensor([ True, False, False])

        >>> ttorch.isclose(
        ...     ttorch.tensor({
        ...         'a': [1., 2, 3],
        ...         'b': {'x': [[float('inf'), 4, 1e20],
        ...                     [-math.inf, 2.2943, 9483.32]]},
        ...     }),
        ...     ttorch.tensor({
        ...         'a': [1 + 1e-10, 3, 4],
        ...         'b': {'x': [[math.inf, 6, 1e20+1],
        ...                     [-float('inf'), 2.294300000001, 9484.32]]},
        ...     }),
        ... )
        <Tensor 0x7f5b3219f370>
        ├── a --> tensor([ True, False, False])
        └── b --> <Tensor 0x7f5b3219f550>
            └── x --> tensor([[ True, False,  True],
                              [ True,  True, False]])
    """
    return torch.isclose(input, other, *args, **kwargs)