code: def random_pairs_with_replacement(n, shape, random_state=None):
      
  
      if not isinstance(random_state, np.random.RandomState):
          random_state = np.random.RandomState(random_state)
  
      n_max = max_pairs(shape)
  
      if n_max <= 0:
          raise ValueError('n_max must be larger than 0')
  
      # make random pairs
      indices = random_state.randint(0, n_max, n)
  
      if len(shape) == 1:
          return _map_tril_1d_on_2d(indices, shape[0])
      else:
          return np.unravel_index(indices, shape)
docs: make random record pairs