code: def make_line_segments(
      x: FloatArrayLike, y: FloatArrayLike, ispath=True
  ) -> FloatArray:
      """
      Return an (n x 2 x 2) array of n line segments
  
      Parameters
      ----------
      x : array_like
          x points
      y : array_like
          y points
      ispath : bool
          If True, the points represent a path from one point
          to the next until the last. If False, then each pair
          of successive(even-odd pair) points yields a line.
      """
      # Series objects would otherwise require .iloc
      x = np.asarray(x)
      y = np.asarray(y)
      if ispath:
          x = interleave(x[:-1], x[1:])
          y = interleave(y[:-1], y[1:])
      elif len(x) % 2:
          raise PlotnineError("Expects an even number of points")
  
      n = len(x) // 2
      segments = np.reshape(list(zip(x, y)), [n, 2, 2])
      return segments
  
imports: from __future__ import annotations
  import inspect
  import itertools
  import warnings
  from collections import defaultdict
  from collections.abc import Iterable, Sequence
  from contextlib import suppress
  from typing import TYPE_CHECKING, cast, overload
  from warnings import warn
  import numpy
  import pandas
  from pandas.core.groupby import DataFrameGroupBy
  from ..exceptions import PlotnineError, PlotnineWarning
  from ..mapping import aes
label_desc: Use image node_id 21 for calling a global function with example usage: make_line_segments(x, y, ispath) and returns: segments