code: def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
      clipped_xlines = []
      clipped_ylines = []
  
      _pos_angles = []
  
      if xdir:
          xsign = 1
      else:
          xsign = -1
  
      if ydir:
          ysign = 1
      else:
          ysign = -1
  
      for x, y in zip(xlines, ylines):
          if clip in ["up", "right"]:
              b = (x < x0).astype("i")
              db = b[1:] - b[:-1]
          else:
              b = (x > x0).astype("i")
              db = b[1:] - b[:-1]
  
          if b[0]:
              ns = 0
          else:
              ns = -1
          segx, segy = [], []
          for (i,) in np.argwhere(db != 0):
              c = db[i]
              if c == -1:
                  dx = x0 - x[i]
                  dy = (y[i + 1] - y[i]) * (dx / (x[i + 1] - x[i]))
                  y0 = y[i] + dy
                  clipped_xlines.append(
                      np.concatenate([segx, x[ns : i + 1], [x0]])
                  )
                  clipped_ylines.append(
                      np.concatenate([segy, y[ns : i + 1], [y0]])
                  )
                  ns = -1
                  segx, segy = [], []
  
                  if dx == 0.0 and dy == 0:
                      dx = x[i + 1] - x[i]
                      dy = y[i + 1] - y[i]
  
                  a = degrees(atan2(ysign * dy, xsign * dx))
                  _pos_angles.append((x0, y0, a))
  
              elif c == 1:
                  dx = x0 - x[i]
                  dy = (y[i + 1] - y[i]) * (dx / (x[i + 1] - x[i]))
                  y0 = y[i] + dy
                  segx, segy = [x0], [y0]
                  ns = i + 1
  
                  if dx == 0.0 and dy == 0:
                      dx = x[i + 1] - x[i]
                      dy = y[i + 1] - y[i]
  
                  a = degrees(atan2(ysign * dy, xsign * dx))
                  _pos_angles.append((x0, y0, a))
  
          if ns != -1:
              clipped_xlines.append(np.concatenate([segx, x[ns:]]))
              clipped_ylines.append(np.concatenate([segy, y[ns:]]))
  
          # clipped_pos_angles.append(_pos_angles)
  
      return clipped_xlines, clipped_ylines, _pos_angles
  
file_path: catboost/contrib/python/matplotlib/py2/mpl_toolkits/axisartist/clip_path.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  from six.moves import zip
  import numpy
  from math import degrees
  import math
  import warnings
label_desc: Use image node_id 2 for calling a global function with example usage: clip(xlines, ylines, x0, clip, xdir, ydir) and returns: clipped_xlines,  clipped_ylines,  _pos_angles