code: def _build_transition_matrix(
      num_items, concentration_parameter, random_state, atol=0.001
  ):
      def _is_doubly_stochastic(matrix, atol):
          return np.all(
              np.abs(1.0 - matrix.sum(axis=0)) < atol
          ) and np.all(np.abs(1.0 - matrix.sum(axis=1)) < atol)
  
      transition_matrix = random_state.dirichlet(
          np.repeat(concentration_parameter, num_items), num_items
      )
  
      for _ in range(100):
          if _is_doubly_stochastic(transition_matrix, atol):
              break
  
          transition_matrix /= transition_matrix.sum(axis=0)
          transition_matrix /= transition_matrix.sum(1)[:, np.newaxis]
  
      return transition_matrix
  
imports: import numpy
  from spotlight.interactions import Interactions
label_desc: Use image node_id 1 for calling a global function with example usage: _build_transition_matrix(num_items, concentration_parameter, random_state, atol) and returns: transition_matrix, unknown