code: def lbest_idx(state, idx):
      
      swarm = state.swarm
      n_s = state.params['n_s']
      cmp = comparator(swarm[0].best_fitness)
      indices = __lbest_indices__(len(swarm), n_s, idx)
      best = None
      for i in indices:
          if best is None or cmp(swarm[i].best_fitness, swarm[best].best_fitness):
              best = i
      return best
docs: lbest Neighbourhood topology function.
  
      Neighbourhood size is determined by state.params['n_s'].
  
      Args:
          state: cipy.algorithms.pso.State: The state of the PSO algorithm.
          idx: int: index of the particle in the swarm.
  
      Returns:
          int: The index of the lbest particle.