code: def cal_total_distance(routine):
      """The objective function. input routine, return total distance.
      cal_total_distance(np.arange(num_points))
      """
      (num_points,) = routine.shape
      return (
          distance_matrix[0, routine[0]]
          + sum(
              [
                  distance_matrix[
                      routine[i % num_points],
                      routine[(i + 1) % num_points],
                  ]
                  for i in range(num_points)
              ]
          )
          + distance_matrix[routine[-1], 0]
      )
  
imports: import numpy
  from scipy import spatial
  import matplotlib.pyplot
  from sko.GA import GA_TSP
label_desc: Use image node_id 1 for calling a global function with example usage: cal_total_distance(routine) and returns: unknown