


torch.linalg.matrix_rank(A)
      tensor([2, 2, 2, 2])



  >>> A = torch.randn(2, 4, 2, 3)
  >>> torch.linalg.matrix_rank(A)
  tensor([[2, 2, 2, 2],
          [2, 2, 2, 2]])

  >>> A = torch.randn(2, 4, 3, 3, dtype=torch.complex64)
  >>> torch.linalg.matrix_rank(A)
  tensor([[3, 3, 3, 3],
          [3, 3, 3, 3]])
  >>> torch.linalg.matrix_rank(A, hermitian=True)
  tensor([[3, 3, 3, 3],
          [3, 3, 3, 3]])
  >>> torch.linalg.matrix_rank(A, atol=1.0, rtol=0.0)
  tensor([[3, 2, 2, 2],
          [1, 2, 1, 2]])
  >>> torch.linalg.matrix_rank(A, atol=1.0, rtol=0.0, hermitian=True)
  tensor([[2, 2, 2, 1],
          [1, 2, 2, 2]])
