code: def _choose_pivot_row(A, B, candidate_rows, pivot_col, Y):
      # Choose row with smallest ratio
      first_row = candidate_rows[0]
      min_ratio = B[first_row] / A[first_row, pivot_col]
      min_rows = [first_row]
      for i in candidate_rows[1:]:
          ratio = B[i] / A[i, pivot_col]
          if ratio < min_ratio:
              min_ratio = ratio
              min_rows = [i]
          elif ratio == min_ratio:
              min_rows.append(i)
  
      # If there are ties, pick using Bland's rule
      _, row = min((Y[i], i) for i in min_rows)
      return row
  
imports: from sympy.core import sympify
  from sympy.core.exprtools import factor_terms
  from sympy.core.relational import Le, Ge, Eq
  from sympy.core.singleton import S
  from sympy.core.symbol import Dummy
  from sympy.core.sorting import ordered
  from sympy.functions.elementary.complexes import sign
  from sympy.matrices.dense import Matrix, zeros
  from sympy.solvers.solveset import linear_eq_to_matrix
  from sympy.utilities.iterables import numbered_symbols
  from sympy.utilities.misc import filldedent
label_desc: Use image node_id 2 for calling a global function with example usage: _choose_pivot_row(A, B, candidate_rows, pivot_col, Y) and returns: row