code: def sample_inputs_matrix_rank(
      op_info, device, dtype, requires_grad=False, **kwargs
  ):
      """
      This function produces inputs for matrix rank that test
      all possible combinations for atol and rtol
      """
  
      def make_tol_arg(kwarg_type, inp):
          if kwarg_type == "none":
              return None
          if kwarg_type == "float":
              return 1.0
          assert kwarg_type == "tensor"
          return torch.ones(inp.shape[:-2], device=device)
  
      for tol_type in ["float", "tensor"]:
          for atol_type, rtol_type in product(
              ["none", tol_type], repeat=2
          ):
              if (
                  not atol_type and not rtol_type
              ):  # default behavior, so skipped here so it's not tested 2 extra times
                  continue
              for sample in sample_inputs_linalg_invertible(
                  op_info, device, dtype, requires_grad
              ):
                  assert sample.kwargs == {}
                  sample.kwargs = {
                      "atol": make_tol_arg(atol_type, sample.input),
                      "rtol": make_tol_arg(rtol_type, sample.input),
                  }
                  yield sample
  
      # default kwargs
      yield from sample_inputs_linalg_invertible(
          op_info, device, dtype, requires_grad
      )
  
imports: import itertools
  import random
  import unittest
  from functools import partial
  from itertools import chain, product
  from typing import Iterable, List, Tuple
  import numpy
  from numpy import inf
  import torch
  from torch.testing import make_tensor
  from torch.testing._internal.common_cuda import _get_magma_version, _get_torch_cuda_version, with_tf32_off
  from torch.testing._internal.common_device_type import has_cusolver, skipCPUIfNoLapack, skipCUDAIf, skipCUDAIfNoCusolver, skipCUDAIfNoMagma, skipCUDAIfNoMagmaAndNoCusolver, skipCUDAIfNoMagmaAndNoLinalgsolver, skipCUDAIfRocm, tol, toleranceOverride
  from torch.testing._internal.common_dtype import all_types_and_complex, all_types_and_complex_and, floating_and_complex_types, floating_and_complex_types_and, get_all_complex_dtypes
  from torch.testing._internal.common_utils import GRADCHECK_NONDET_TOL, IS_MACOS, make_fullrank_matrices_with_distinct_singular_values, skipIfSlowGradcheckEnv, slowTest, TEST_WITH_ROCM
  from torch.testing._internal.opinfo.core import clone_sample, DecorateInfo, ErrorInput, gradcheck_wrapper_hermitian_input, L, M, OpInfo, ReductionOpInfo, S, SampleInput
  from torch.testing._internal.opinfo.refs import PythonRefInfo, ReductionPythonRefInfo
label_desc: Use image node_id 15 for calling a global function with example usage: sample_inputs_matrix_rank(op_info, device, dtype, requires_grad) and returns: torch, None, int