#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Functional interface."""

from typing import TYPE_CHECKING

from torch.nn.functional import (
    adaptive_avg_pool1d,
    adaptive_avg_pool2d,
    adaptive_avg_pool3d,
    adaptive_max_pool1d,
    adaptive_max_pool1d_with_indices,
    adaptive_max_pool2d,
    adaptive_max_pool2d_with_indices,
    adaptive_max_pool3d,
    adaptive_max_pool3d_with_indices,
    affine_grid,
    alpha_dropout,
    avg_pool1d,
    avg_pool2d,
    avg_pool3d,
    batch_norm,
    bilinear,
    binary_cross_entropy,
    binary_cross_entropy_with_logits,
    celu,
    celu_,
    channel_shuffle,
    conv1d,
    conv2d,
    conv3d,
    conv_tbc,
    conv_transpose1d,
    conv_transpose2d,
    conv_transpose3d,
    cosine_embedding_loss,
    cosine_similarity,
    cross_entropy,
    ctc_loss,
    dropout,
    dropout2d,
    dropout3d,
    embedding,
    embedding_bag,
    feature_alpha_dropout,
    fractional_max_pool2d,
    fractional_max_pool2d_with_indices,
    fractional_max_pool3d,
    fractional_max_pool3d_with_indices,
    group_norm,
    hardshrink,
    hinge_embedding_loss,
    instance_norm,
    kl_div,
    layer_norm,
    log_softmax,
    margin_ranking_loss,
    max_pool1d,
    max_pool1d_with_indices,
    max_pool2d,
    max_pool2d_with_indices,
    max_pool3d,
    max_pool3d_with_indices,
    max_unpool1d,
    max_unpool2d,
    max_unpool3d,
    mish,
    mse_loss,
    multi_head_attention_forward,
    multi_margin_loss,
    multilabel_margin_loss,
    multilabel_soft_margin_loss,
    pad,
    pairwise_distance,
    pdist,
    pixel_shuffle,
    pixel_unshuffle,
    poisson_nll_loss,
    prelu,
    relu,
    relu_,
    rrelu,
    rrelu_,
    selu,
    selu_,
    sigmoid,
    soft_margin_loss,
    softmax,
    softsign,
    tanh,
    tanhshrink,
    threshold,
    triplet_margin_loss,
    triplet_margin_with_distance_loss,
)

if TYPE_CHECKING:
    from .activation import log_softmax_multidim, softmax_multidim
    from .checksum import checksum_any
    from .cropping import crop_dim, crop_dims
    from .indices import (
        get_inverse_perm,
        get_perm_indices,
        insert_at_indices,
        randperm_diff,
        remove_at_indices,
    )
    from .make import (
        as_device,
        as_dtype,
        as_generator,
        get_default_device,
        get_default_dtype,
        get_default_generator,
        set_default_dtype,
        set_default_generator,
    )
    from .mask import (
        generate_square_subsequent_mask,
        lengths_to_non_pad_mask,
        lengths_to_pad_mask,
        lengths_to_ratios,
        masked_equal,
        masked_mean,
        masked_sum,
        non_pad_mask_to_lengths,
        non_pad_mask_to_ratios,
        pad_mask_to_lengths,
        pad_mask_to_ratios,
        ratios_to_lengths,
        ratios_to_non_pad_mask,
        ratios_to_pad_mask,
        tensor_to_lengths,
        tensor_to_non_pad_mask,
        tensor_to_pad_mask,
        tensor_to_tensors_list,
        tensors_list_to_lengths,
    )
    from .multiclass import (
        index_to_name,
        index_to_onehot,
        name_to_index,
        name_to_onehot,
        one_hot,
        onehot_to_index,
        onehot_to_name,
        probs_to_index,
        probs_to_name,
        probs_to_onehot,
    )
    from .multilabel import (
        indices_to_multihot,
        indices_to_multinames,
        multi_indices_to_multihot,
        multi_indices_to_multinames,
        multihot_to_indices,
        multihot_to_multi_indices,
        multihot_to_multinames,
        multinames_to_indices,
        multinames_to_multi_indices,
        multinames_to_multihot,
        probs_to_indices,
        probs_to_multi_indices,
        probs_to_multihot,
        probs_to_multinames,
    )
    from .new import arange, empty, full, ones, rand, randint, randn, randperm, zeros
    from .others import (
        average_power,
        cat,
        concat,
        count_parameters,
        deep_equal,
        equal,
        find,
        get_ndim,
        get_shape,
        initial_seed,
        manual_seed,
        matmul,
        mse,
        ndim,
        nelement,
        no_grad,
        prod,
        ranks,
        rmse,
        seed,
        shape,
        split,
        stack,
        where,
    )
    from .padding import cat_padded_batch, pad_and_stack_rec, pad_dim, pad_dims
    from .powerset import multilabel_to_powerset, powerset_to_multilabel
    from .predicate import (
        all_eq,
        all_ne,
        is_complex,
        is_convertible_to_tensor,
        is_floating_point,
        is_full,
        is_sorted,
        is_stackable,
        is_tensor,
        is_unique,
    )
    from .segments import (
        activity_to_segments,
        activity_to_segments_list,
        segments_list_to_activity,
        segments_to_activity,
        segments_to_segments_list,
    )
    from .transform import (  # noqa: F811
        as_tensor,
        flatten,
        identity,
        move_to,
        move_to_rec,
        pad_and_crop_dim,
        recursive_to,
        repeat_interleave_nd,
        resample_nearest_freqs,
        resample_nearest_rates,
        resample_nearest_steps,
        shuffled,
        squeeze,
        squeeze_,
        squeeze_copy,
        to_item,
        to_tensor,
        top_k,
        top_p,
        topk,
        transform_drop,
        unsqueeze,
        unsqueeze_,
        unsqueeze_copy,
        view_as_complex,
        view_as_real,
    )

else:
    import lazy_loader as lazy

    __getattr__, __dir__, __all__ = lazy.attach(
        __name__,
        submodules=[
            "activation",
            "checksum",
            "cropping",
            "indices",
            "make",
            "mask",
            "multiclass",
            "multilabel",
            "new",
            "others",
            "padding",
            "powerset",
            "predicate",
            "segments",
            "transform",
        ],
        submod_attrs={
            "activation": ["log_softmax_multidim", "softmax_multidim"],
            "checksum": ["checksum_any"],
            "cropping": ["crop_dim", "crop_dims"],
            "indices": [
                "get_inverse_perm",
                "get_perm_indices",
                "insert_at_indices",
                "randperm_diff",
                "remove_at_indices",
            ],
            "make": [
                "as_device",
                "as_dtype",
                "as_generator",
                "get_default_device",
                "get_default_dtype",
                "get_default_generator",
                "set_default_dtype",
                "set_default_generator",
            ],
            "mask": [
                "generate_square_subsequent_mask",
                "lengths_to_non_pad_mask",
                "lengths_to_pad_mask",
                "lengths_to_ratios",
                "masked_equal",
                "masked_mean",
                "masked_sum",
                "non_pad_mask_to_lengths",
                "non_pad_mask_to_ratios",
                "pad_mask_to_lengths",
                "pad_mask_to_ratios",
                "ratios_to_lengths",
                "ratios_to_non_pad_mask",
                "ratios_to_pad_mask",
                "tensor_to_lengths",
                "tensor_to_non_pad_mask",
                "tensor_to_pad_mask",
                "tensor_to_tensors_list",
                "tensors_list_to_lengths",
            ],
            "multiclass": [
                "index_to_name",
                "index_to_onehot",
                "name_to_index",
                "name_to_onehot",
                "one_hot",
                "onehot_to_index",
                "onehot_to_name",
                "probs_to_index",
                "probs_to_name",
                "probs_to_onehot",
            ],
            "multilabel": [
                "indices_to_multihot",
                "indices_to_multinames",
                "multi_indices_to_multihot",
                "multi_indices_to_multinames",
                "multihot_to_indices",
                "multihot_to_multi_indices",
                "multihot_to_multinames",
                "multinames_to_indices",
                "multinames_to_multi_indices",
                "multinames_to_multihot",
                "probs_to_indices",
                "probs_to_multi_indices",
                "probs_to_multihot",
                "probs_to_multinames",
            ],
            "new": [
                "arange",
                "empty",
                "full",
                "ones",
                "rand",
                "randn",
                "randint",
                "randperm",
                "zeros",
            ],
            "others": [
                "average_power",
                "cat",
                "concat",
                "count_parameters",
                "deep_equal",
                "find",
                "get_ndim",
                "get_shape",
                "mse",
                "ndim",
                "nelement",
                "prod",
                "ranks",
                "rmse",
                "shape",
                "stack",
                "equal",
                "initial_seed",
                "manual_seed",
                "matmul",
                "no_grad",
                "seed",
                "split",
                "where",
            ],
            "padding": ["cat_padded_batch", "pad_and_stack_rec", "pad_dim", "pad_dims"],
            "powerset": ["multilabel_to_powerset", "powerset_to_multilabel"],
            "predicate": [
                "all_eq",
                "all_ne",
                "is_complex",
                "is_convertible_to_tensor",
                "is_floating_point",
                "is_full",
                "is_sorted",
                "is_stackable",
                "is_tensor",
                "is_unique",
            ],
            "segments": [
                "activity_to_segments",
                "activity_to_segments_list",
                "segments_list_to_activity",
                "segments_to_activity",
                "segments_to_segments_list",
            ],
            "transform": [
                "as_tensor",
                "flatten",
                "identity",
                "move_to",
                "move_to_rec",
                "pad_and_crop_dim",
                "recursive_to",
                "repeat_interleave_nd",
                "resample_nearest_freqs",
                "resample_nearest_rates",
                "resample_nearest_steps",
                "shuffled",
                "squeeze",
                "squeeze_",
                "squeeze_copy",
                "to_item",
                "to_tensor",
                "top_k",
                "top_p",
                "topk",
                "transform_drop",
                "unsqueeze",
                "unsqueeze_",
                "unsqueeze_copy",
                "view_as_complex",
                "view_as_real",
            ],
        },
    )


del TYPE_CHECKING
