code: def lines_to_path(lines):
      
      lines = np.asanyarray(lines, dtype=np.float64)
  
      if util.is_shape(lines, (-1, (2, 3))):
          # the case where we have a list of points
          # we are going to assume they are connected
          result = {'entities': np.array([Line(np.arange(len(lines)))]),
                    'vertices': lines}
          return result
      elif util.is_shape(lines, (-1, 2, (2, 3))):
          # case where we have line segments in 2D or 3D
          dimension = lines.shape[-1]
          # convert lines to even number of (n, dimension) points
          lines = lines.reshape((-1, dimension))
          # merge duplicate vertices
          unique, inverse = grouping.unique_rows(lines)
          # use scipy edges_to_path to skip creating
          # a bajillion individual line entities which
          # will be super slow vs. fewer polyline entities
          return edges_to_path(edges=inverse.reshape((-1, 2)),
                               vertices=lines[unique])
      else:
          raise ValueError('Lines must be (n,(2|3)) or (n,2,(2|3))')
      return result
docs: Turn line segments into a Path2D or Path3D object.
  
      Parameters
      ------------
      lines : (n, 2, dimension) or (n, dimension) float
        Line segments or connected polyline curve in 2D or 3D
  
      Returns
      -----------
      kwargs : dict
        kwargs for Path constructor