def dist(x, y, p=2, name=None):
    '\n\n    This OP returns the p-norm of (x - y). It is not a norm in a strict sense, only as a measure\n    of distance. The shapes of x and y must be broadcastable. The definition is as follows, for\n    details, please refer to the `numpy\'s broadcasting <https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html>`_:\n\n    - Each input has at least one dimension.\n    - Match the two input dimensions from back to front, the dimension sizes must either be equal, one of them is 1, or one of them does not exist.\n\n    Where, z = x - y, the shapes of x and y are broadcastable, then the shape of z can be\n    obtained as follows:\n\n    1. If the number of dimensions of x and y are not equal, prepend 1 to the dimensions of the\n    tensor with fewer dimensions.\n\n    For example, The shape of x is [8, 1, 6, 1], the shape of y is [7, 1, 5], prepend 1 to the\n    dimension of y.\n\n    x (4-D Tensor):  8 x 1 x 6 x 1\n\n    y (4-D Tensor):  1 x 7 x 1 x 5\n\n    2. Determine the size of each dimension of the output z: choose the maximum value from the\n    two input dimensions.\n\n    z (4-D Tensor):  8 x 7 x 6 x 5\n\n    If the number of dimensions of the two inputs are the same, the size of the output can be\n    directly determined in step 2. When p takes different values, the norm formula is as follows:\n\n    When p = 0, defining $0^0=0$, the zero-norm of z is simply the number of non-zero elements of z.\n\n    .. math::\n\n        ||z||_{0}=\\lim_{p \\\\rightarrow 0}\\sum_{i=1}^{m}|z_i|^{p}\n\n    When p = inf, the inf-norm of z is the maximum element of z.\n\n    .. math::\n\n        ||z||_\\infty=\\max_i |z_i|\n\n    When p = -inf, the negative-inf-norm of z is the minimum element of z.\n\n    .. math::\n\n        ||z||_{-\\infty}=\\min_i |z_i|\n\n    Otherwise, the p-norm of z follows the formula,\n\n    .. math::\n\n        ||z||_{p}=(\\sum_{i=1}^{m}|z_i|^p)^{\\\\frac{1}{p}}\n\n    Args:\n        x (Tensor): 1-D to 6-D Tensor, its data type is float32 or float64.\n        y (Tensor): 1-D to 6-D Tensor, its data type is float32 or float64.\n        p (float, optional): The norm to be computed, its data type is float32 or float64. Default: 2.\n\n    Returns:\n        Tensor: Tensor that is the p-norm of (x - y).\n\n    Examples:\n        .. code-block:: python\n\n            import paddle\n            import numpy as np\n\n            x = paddle.to_tensor(np.array([[3, 3],[3, 3]]), "float32")\n            y = paddle.to_tensor(np.array([[3, 3],[3, 1]]), "float32")\n            out = paddle.dist(x, y, 0)\n            print(out) # out = [1.]\n\n            out = paddle.dist(x, y, 2)\n            print(out) # out = [2.]\n\n            out = paddle.dist(x, y, float("inf"))\n            print(out) # out = [2.]\n\n            out = paddle.dist(x, y, float("-inf"))\n            print(out) # out = [0.]\n    '
    check_variable_and_dtype(x, 'dtype', ['float32', 'float64'], 'dist')
    check_variable_and_dtype(y, 'dtype', ['float32', 'float64'], 'dist')
    check_type(p, 'p', (float, int), 'dist')
    helper = LayerHelper('dist', **locals())
    out = helper.create_variable_for_type_inference(x.dtype)
    inputs = {'X': [x], 'Y': [y]}
    outputs = {'Out': [out]}
    attrs = {'p': float(p)}
    helper.append_op(type='dist', inputs=inputs, outputs={'Out': out}, attrs=attrs)
    return out
This OP returns the p-norm of (x - y). It is not a norm in a strict sense, only as a measure
of distance. The shapes of x and y must be broadcastable. The definition is as follows, for
details, please refer to the `numpy's broadcasting <https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html>`_:

- Each input has at least one dimension.
- Match the two input dimensions from back to front, the dimension sizes must either be equal, one of them is 1, or one of them does not exist.

Where, z = x - y, the shapes of x and y are broadcastable, then the shape of z can be
obtained as follows:

1. If the number of dimensions of x and y are not equal, prepend 1 to the dimensions of the
tensor with fewer dimensions.

For example, The shape of x is [8, 1, 6, 1], the shape of y is [7, 1, 5], prepend 1 to the
dimension of y.

x (4-D Tensor):  8 x 1 x 6 x 1

y (4-D Tensor):  1 x 7 x 1 x 5

2. Determine the size of each dimension of the output z: choose the maximum value from the
two input dimensions.

z (4-D Tensor):  8 x 7 x 6 x 5

If the number of dimensions of the two inputs are the same, the size of the output can be
directly determined in step 2. When p takes different values, the norm formula is as follows:

When p = 0, defining $0^0=0$, the zero-norm of z is simply the number of non-zero elements of z.

.. math::

    ||z||_{0}=\lim_{p \\rightarrow 0}\sum_{i=1}^{m}|z_i|^{p}

When p = inf, the inf-norm of z is the maximum element of z.

.. math::

    ||z||_\infty=\max_i |z_i|

When p = -inf, the negative-inf-norm of z is the minimum element of z.

.. math::

    ||z||_{-\infty}=\min_i |z_i|

Otherwise, the p-norm of z follows the formula,

.. math::

    ||z||_{p}=(\sum_{i=1}^{m}|z_i|^p)^{\\frac{1}{p}}

Args:
    x (Tensor): 1-D to 6-D Tensor, its data type is float32 or float64.
    y (Tensor): 1-D to 6-D Tensor, its data type is float32 or float64.
    p (float, optional): The norm to be computed, its data type is float32 or float64. Default: 2.

Returns:
    Tensor: Tensor that is the p-norm of (x - y).

Examples:
    .. code-block:: python

        import paddle
        import numpy as np

        x = paddle.to_tensor(np.array([[3, 3],[3, 3]]), "float32")
        y = paddle.to_tensor(np.array([[3, 3],[3, 1]]), "float32")
        out = paddle.dist(x, y, 0)
        print(out) # out = [1.]

        out = paddle.dist(x, y, 2)
        print(out) # out = [2.]

        out = paddle.dist(x, y, float("inf"))
        print(out) # out = [2.]

        out = paddle.dist(x, y, float("-inf"))
        print(out) # out = [0.]
def dist(x, y, p=2, name=None):
    '\n\n    This OP returns the p-norm of (x - y). It is not a norm in a strict sense, only as a measure\n    of distance. The shapes of x and y must be broadcastable. The definition is as follows, for\n    details, please refer to the `numpy\'s broadcasting <https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html>`_:\n\n    - Each input has at least one dimension.\n    - Match the two input dimensions from back to front, the dimension sizes must either be equal, one of them is 1, or one of them does not exist.\n\n    Where, z = x - y, the shapes of x and y are broadcastable, then the shape of z can be\n    obtained as follows:\n\n    1. If the number of dimensions of x and y are not equal, prepend 1 to the dimensions of the\n    tensor with fewer dimensions.\n\n    For example, The shape of x is [8, 1, 6, 1], the shape of y is [7, 1, 5], prepend 1 to the\n    dimension of y.\n\n    x (4-D Tensor):  8 x 1 x 6 x 1\n\n    y (4-D Tensor):  1 x 7 x 1 x 5\n\n    2. Determine the size of each dimension of the output z: choose the maximum value from the\n    two input dimensions.\n\n    z (4-D Tensor):  8 x 7 x 6 x 5\n\n    If the number of dimensions of the two inputs are the same, the size of the output can be\n    directly determined in step 2. When p takes different values, the norm formula is as follows:\n\n    When p = 0, defining $0^0=0$, the zero-norm of z is simply the number of non-zero elements of z.\n\n    .. math::\n\n        ||z||_{0}=\\lim_{p \\\\rightarrow 0}\\sum_{i=1}^{m}|z_i|^{p}\n\n    When p = inf, the inf-norm of z is the maximum element of z.\n\n    .. math::\n\n        ||z||_\\infty=\\max_i |z_i|\n\n    When p = -inf, the negative-inf-norm of z is the minimum element of z.\n\n    .. math::\n\n        ||z||_{-\\infty}=\\min_i |z_i|\n\n    Otherwise, the p-norm of z follows the formula,\n\n    .. math::\n\n        ||z||_{p}=(\\sum_{i=1}^{m}|z_i|^p)^{\\\\frac{1}{p}}\n\n    Args:\n        x (Tensor): 1-D to 6-D Tensor, its data type is float32 or float64.\n        y (Tensor): 1-D to 6-D Tensor, its data type is float32 or float64.\n        p (float, optional): The norm to be computed, its data type is float32 or float64. Default: 2.\n\n    Returns:\n        Tensor: Tensor that is the p-norm of (x - y).\n\n    Examples:\n        .. code-block:: python\n\n            import paddle\n            import numpy as np\n\n            x = paddle.to_tensor(np.array([[3, 3],[3, 3]]), "float32")\n            y = paddle.to_tensor(np.array([[3, 3],[3, 1]]), "float32")\n            out = paddle.dist(x, y, 0)\n            print(out) # out = [1.]\n\n            out = paddle.dist(x, y, 2)\n            print(out) # out = [2.]\n\n            out = paddle.dist(x, y, float("inf"))\n            print(out) # out = [2.]\n\n            out = paddle.dist(x, y, float("-inf"))\n            print(out) # out = [0.]\n    '
    check_variable_and_dtype(x, 'dtype', ['float32', 'float64'], 'dist')
    check_variable_and_dtype(y, 'dtype', ['float32', 'float64'], 'dist')
    check_type(p, 'p', (float, int), 'dist')
    helper = LayerHelper('dist', **locals())
    out = helper.create_variable_for_type_inference(x.dtype)
    inputs = {'X': [x], 'Y': [y]}
    outputs = {'Out': [out]}
    attrs = {'p': float(p)}
    helper.append_op(type='dist', inputs=inputs, outputs={'Out': out}, attrs=attrs)
    return out