def matrix_rank(x, tol=None, hermitian=False, name=None):
    '\n    Computes the rank of a matrix.\n\n    The rank of a matrix is the number of singular values that are greater than the specified `tol` threshold when hermitian=False,\n    or the number of eigenvalues in absolute value that are greater than the specified `tol` threshold when hermitian=True.\n\n    Args:\n        x (Tensor): The input tensor. Its shape should be `[..., m, n]`, where `...` is zero or more batch dimensions. If `x` is a batch\n            of matrices then the output has the same batch dimensions. The data type of `x` should be float32 or float64.\n        tol (float,Tensor,optional): the tolerance value. Default: None. If `tol` is not specified, and `sigma` is the largest\n            singular value (or eigenvalues in absolute value), and `eps` is the epsilon value for the dtype of `x`, then `tol` is computed\n            with formula `tol=sigma * max(m,n) * eps`. Note that if `x` is a batch of matrices, `tol` is computed this way for every batch.\n        hermitian (bool,optional): indicates whether `x` is Hermitian. Default: False. When hermitian=True, `x` is assumed to be Hermitian,\n            enabling a more efficient method for finding eigenvalues, but `x` is not checked inside the function. Instead, We just use\n            the lower triangular of the matrix to compute.\n        name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.\n\n    Returns:\n        Tensor: Rank of tensor x.\n\n    Examples:\n        .. code-block:: python\n\n            import paddle\n\n            a = paddle.eye(10)\n            b = paddle.linalg.matrix_rank(a)\n            print(b)\n            # b = [10]\n\n            c = paddle.ones(shape=[3, 4, 5, 5])\n            d = paddle.linalg.matrix_rank(c, tol=0.01, hermitian=True)\n            print(d)\n            # d = [[1, 1, 1, 1],\n            #      [1, 1, 1, 1],\n            #      [1, 1, 1, 1]]\n\n    '
    if paddle.in_dynamic_mode():
        if (tol is None):
            tol_tensor = None
            tol_attr = 0.0
            use_default_tol = True
        elif isinstance(tol, Variable):
            if (tol.dtype != x.dtype):
                tol_tensor = cast(tol, x.dtype)
            else:
                tol_tensor = tol
            tol_attr = 0.0
            use_default_tol = False
        else:
            tol_tensor = None
            tol_attr = float(tol)
            use_default_tol = False
        return _C_ops.matrix_rank(x, tol_tensor, 'tol', tol_attr, 'hermitian', hermitian, 'use_default_tol', use_default_tol)
    inputs = {}
    attrs = {}
    check_variable_and_dtype(x, 'x', ['float32', 'float64'], 'matrix_rank')
    inputs['X'] = x
    if (tol is None):
        attrs['use_default_tol'] = True
    elif isinstance(tol, Variable):
        check_variable_and_dtype(tol, 'tol', ['float32'], 'matrix_rank')
        attrs['use_default_tol'] = False
        if (tol.dtype != x.dtype):
            inputs['TolTensor'] = cast(tol, x.dtype)
        else:
            inputs['TolTensor'] = tol
    else:
        check_type(tol, 'tol', float, 'matrix_rank')
        attrs['use_default_tol'] = False
        attrs['tol'] = tol
    check_type(hermitian, 'hermitian', bool, 'matrix_rank')
    attrs['hermitian'] = hermitian
    helper = LayerHelper('matrix_rank', **locals())
    out = helper.create_variable_for_type_inference(dtype='int32')
    helper.append_op(type='matrix_rank', inputs=inputs, outputs={'Out': out}, attrs=attrs)
    return out
Computes the rank of a matrix.

The rank of a matrix is the number of singular values that are greater than the specified `tol` threshold when hermitian=False,
or the number of eigenvalues in absolute value that are greater than the specified `tol` threshold when hermitian=True.

Args:
    x (Tensor): The input tensor. Its shape should be `[..., m, n]`, where `...` is zero or more batch dimensions. If `x` is a batch
        of matrices then the output has the same batch dimensions. The data type of `x` should be float32 or float64.
    tol (float,Tensor,optional): the tolerance value. Default: None. If `tol` is not specified, and `sigma` is the largest
        singular value (or eigenvalues in absolute value), and `eps` is the epsilon value for the dtype of `x`, then `tol` is computed
        with formula `tol=sigma * max(m,n) * eps`. Note that if `x` is a batch of matrices, `tol` is computed this way for every batch.
    hermitian (bool,optional): indicates whether `x` is Hermitian. Default: False. When hermitian=True, `x` is assumed to be Hermitian,
        enabling a more efficient method for finding eigenvalues, but `x` is not checked inside the function. Instead, We just use
        the lower triangular of the matrix to compute.
    name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.

Returns:
    Tensor: Rank of tensor x.

Examples:
    .. code-block:: python

        import paddle

        a = paddle.eye(10)
        b = paddle.linalg.matrix_rank(a)
        print(b)
        # b = [10]

        c = paddle.ones(shape=[3, 4, 5, 5])
        d = paddle.linalg.matrix_rank(c, tol=0.01, hermitian=True)
        print(d)
        # d = [[1, 1, 1, 1],
        #      [1, 1, 1, 1],
        #      [1, 1, 1, 1]]
def matrix_rank(x, tol=None, hermitian=False, name=None):
    '\n    Computes the rank of a matrix.\n\n    The rank of a matrix is the number of singular values that are greater than the specified `tol` threshold when hermitian=False,\n    or the number of eigenvalues in absolute value that are greater than the specified `tol` threshold when hermitian=True.\n\n    Args:\n        x (Tensor): The input tensor. Its shape should be `[..., m, n]`, where `...` is zero or more batch dimensions. If `x` is a batch\n            of matrices then the output has the same batch dimensions. The data type of `x` should be float32 or float64.\n        tol (float,Tensor,optional): the tolerance value. Default: None. If `tol` is not specified, and `sigma` is the largest\n            singular value (or eigenvalues in absolute value), and `eps` is the epsilon value for the dtype of `x`, then `tol` is computed\n            with formula `tol=sigma * max(m,n) * eps`. Note that if `x` is a batch of matrices, `tol` is computed this way for every batch.\n        hermitian (bool,optional): indicates whether `x` is Hermitian. Default: False. When hermitian=True, `x` is assumed to be Hermitian,\n            enabling a more efficient method for finding eigenvalues, but `x` is not checked inside the function. Instead, We just use\n            the lower triangular of the matrix to compute.\n        name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.\n\n    Returns:\n        Tensor: Rank of tensor x.\n\n    Examples:\n        .. code-block:: python\n\n            import paddle\n\n            a = paddle.eye(10)\n            b = paddle.linalg.matrix_rank(a)\n            print(b)\n            # b = [10]\n\n            c = paddle.ones(shape=[3, 4, 5, 5])\n            d = paddle.linalg.matrix_rank(c, tol=0.01, hermitian=True)\n            print(d)\n            # d = [[1, 1, 1, 1],\n            #      [1, 1, 1, 1],\n            #      [1, 1, 1, 1]]\n\n    '
    if paddle.in_dynamic_mode():
        if (tol is None):
            tol_tensor = None
            tol_attr = 0.0
            use_default_tol = True
        elif isinstance(tol, Variable):
            if (tol.dtype != x.dtype):
                tol_tensor = cast(tol, x.dtype)
            else:
                tol_tensor = tol
            tol_attr = 0.0
            use_default_tol = False
        else:
            tol_tensor = None
            tol_attr = float(tol)
            use_default_tol = False
        return _C_ops.matrix_rank(x, tol_tensor, 'tol', tol_attr, 'hermitian', hermitian, 'use_default_tol', use_default_tol)
    inputs = {}
    attrs = {}
    check_variable_and_dtype(x, 'x', ['float32', 'float64'], 'matrix_rank')
    inputs['X'] = x
    if (tol is None):
        attrs['use_default_tol'] = True
    elif isinstance(tol, Variable):
        check_variable_and_dtype(tol, 'tol', ['float32'], 'matrix_rank')
        attrs['use_default_tol'] = False
        if (tol.dtype != x.dtype):
            inputs['TolTensor'] = cast(tol, x.dtype)
        else:
            inputs['TolTensor'] = tol
    else:
        check_type(tol, 'tol', float, 'matrix_rank')
        attrs['use_default_tol'] = False
        attrs['tol'] = tol
    check_type(hermitian, 'hermitian', bool, 'matrix_rank')
    attrs['hermitian'] = hermitian
    helper = LayerHelper('matrix_rank', **locals())
    out = helper.create_variable_for_type_inference(dtype='int32')
    helper.append_op(type='matrix_rank', inputs=inputs, outputs={'Out': out}, attrs=attrs)
    return out