code: def search_range(x: int, ri: range, *, side: str) -> int:
      """
  
      Find insertion point in a range to maintain sorted order
  
      Parameters
      ----------
      x
          Integer to insert
      ri
          Range to insert into
      side
          Tie-breaking decision for the case that `x` is a member of the
          range. If `"left"` then the insertion point is before the
          entry, otherwise it is after.
  
      Returns
      -------
      int
          The insertion point
  
      See Also
      --------
      numpy.searchsorted
  
      Notes
      -----
      Let ``p`` be the return value, then if ``side="left"`` the
      following invariants are maintained::
  
          all(x < n for n in ri[:p])
          all(x >= n for n in ri[p:])
  
      Conversely, if ``side="right"`` then we have::
  
          all(x <= n for n in ri[:p])
          all(x > n for n in ri[p:])
  
      Examples
      --------
      For series: 1 4 7
      >>> search_range(4, range(1, 10, 3), side="left")
      1
      >>> search_range(4, range(1, 10, 3), side="right")
      2
      """
      assert side in {"left", "right"}
      if flip := (ri.step < 0):
          ri = ri[::-1]
          shift = int(side == "right")
      else:
          shift = int(side == "left")
  
      offset = (x - ri.start - shift) // ri.step + 1
      if flip:
          offset = len(ri) - offset
      return max(min(len(ri), offset), 0)
  
imports: import decimal
  import functools
  import os
  import traceback
  import warnings
  from typing import FrozenSet, Set, Union
  import numpy
  import pandas
  import rmm
  import cudf
  import cudf.api.types
  from cudf.core import column
  from cudf.core.buffer import as_buffer
label_desc: Use image node_id 7 for calling a global function with example usage: search_range(x, ri) and returns: max