code: def split_path_inout(
      path, inside, tolerence=0.01, reorder_inout=False
  ):
      """divide a path into two segment at the point where inside(x, y)
      becomes False.
      """
  
      path_iter = path.iter_segments()
  
      ctl_points, command = next(path_iter)
      begin_inside = inside(
          ctl_points[-2:]
      )  # true if begin point is inside
  
      ctl_points_old = ctl_points
  
      concat = np.concatenate
  
      iold = 0
      i = 1
  
      for ctl_points, command in path_iter:
          iold = i
          i += len(ctl_points) // 2
          if inside(ctl_points[-2:]) != begin_inside:
              bezier_path = concat([ctl_points_old[-2:], ctl_points])
              break
          ctl_points_old = ctl_points
      else:
          raise ValueError("The path does not intersect with the patch")
  
      bp = bezier_path.reshape((-1, 2))
      left, right = split_bezier_intersecting_with_closedpath(
          bp, inside, tolerence
      )
      if len(left) == 2:
          codes_left = [Path.LINETO]
          codes_right = [Path.MOVETO, Path.LINETO]
      elif len(left) == 3:
          codes_left = [Path.CURVE3, Path.CURVE3]
          codes_right = [Path.MOVETO, Path.CURVE3, Path.CURVE3]
      elif len(left) == 4:
          codes_left = [Path.CURVE4, Path.CURVE4, Path.CURVE4]
          codes_right = [
              Path.MOVETO,
              Path.CURVE4,
              Path.CURVE4,
              Path.CURVE4,
          ]
      else:
          raise AssertionError("This should never be reached")
  
      verts_left = left[1:]
      verts_right = right[:]
  
      if path.codes is None:
          path_in = Path(concat([path.vertices[:i], verts_left]))
          path_out = Path(concat([verts_right, path.vertices[i:]]))
  
      else:
          path_in = Path(
              concat([path.vertices[:iold], verts_left]),
              concat([path.codes[:iold], codes_left]),
          )
  
          path_out = Path(
              concat([verts_right, path.vertices[i:]]),
              concat([codes_right, path.codes[i:]]),
          )
  
      if reorder_inout and begin_inside is False:
          path_in, path_out = path_out, path_in
  
      return path_in, path_out
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  import numpy
  from matplotlib.path import Path
  from operator import xor
  import warnings
label_desc: Use image node_id 8 for calling a global function with example usage: split_path_inout(path, inside, tolerence, reorder_inout) and returns: path_in,  path_out