code: def searchsorted(
      arr: ArrayLike,
      value: NumpyValueArrayLike | ExtensionArray,
      side: Literal["left", "right"] = "left",
      sorter: NumpySorter | None = None,
  ) -> npt.NDArray[np.intp] | np.intp:
      """
      Find indices where elements should be inserted to maintain order.
  
      Find the indices into a sorted array `arr` (a) such that, if the
      corresponding elements in `value` were inserted before the indices,
      the order of `arr` would be preserved.
  
      Assuming that `arr` is sorted:
  
      ======  ================================
      `side`  returned index `i` satisfies
      ======  ================================
      left    ``arr[i-1] < value <= self[i]``
      right   ``arr[i-1] <= value < self[i]``
      ======  ================================
  
      Parameters
      ----------
      arr: np.ndarray, ExtensionArray, Series
          Input array. If `sorter` is None, then it must be sorted in
          ascending order, otherwise `sorter` must be an array of indices
          that sort it.
      value : array-like or scalar
          Values to insert into `arr`.
      side : {'left', 'right'}, optional
          If 'left', the index of the first suitable location found is given.
          If 'right', return the last such index.  If there is no suitable
          index, return either 0 or N (where N is the length of `self`).
      sorter : 1-D array-like, optional
          Optional array of integer indices that sort array a into ascending
          order. They are typically the result of argsort.
  
      Returns
      -------
      array of ints or int
          If value is array-like, array of insertion points.
          If value is scalar, a single integer.
  
      See Also
      --------
      numpy.searchsorted : Similar method from NumPy.
      """
      if sorter is not None:
          sorter = ensure_platform_int(sorter)
  
      if (
          isinstance(arr, np.ndarray)
          and arr.dtype.kind in "iu"
          and (is_integer(value) or is_integer_dtype(value))
      ):
          # if `arr` and `value` have different dtypes, `arr` would be
          # recast by numpy, causing a slow search.
          # Before searching below, we therefore try to give `value` the
          # same dtype as `arr`, while guarding against integer overflows.
          iinfo = np.iinfo(arr.dtype.type)
          value_arr = (
              np.array([value])
              if is_integer(value)
              else np.array(value)
          )
          if (value_arr >= iinfo.min).all() and (
              value_arr <= iinfo.max
          ).all():
              # value within bounds, so no overflow, so can convert value dtype
              # to dtype of arr
              dtype = arr.dtype
          else:
              dtype = value_arr.dtype
  
          if is_integer(value):
              # We know that value is int
              value = cast(int, dtype.type(value))
          else:
              value = pd_array(cast(ArrayLike, value), dtype=dtype)
      else:
          # E.g. if `arr` is an array with dtype='datetime64[ns]'
          # and `value` is a pd.Timestamp, we may need to convert value
          arr = ensure_wrapped_if_datetimelike(arr)
  
      # Argument 1 to "searchsorted" of "ndarray" has incompatible type
      # "Union[NumpyValueArrayLike, ExtensionArray]"; expected "NumpyValueArrayLike"
      return arr.searchsorted(value, side=side, sorter=sorter)
  
imports: from __future__ import annotations
  import decimal
  import operator
  from textwrap import dedent
  from typing import TYPE_CHECKING, Literal, cast
  import warnings
  import numpy
  from pandas._libs import algos, hashtable, iNaT, lib
  from pandas._typing import AnyArrayLike, ArrayLike, ArrayLikeT, AxisInt, DtypeObj, TakeIndexer, npt
  from pandas.util._decorators import doc
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike, np_find_common_type
  from pandas.core.dtypes.common import ensure_float64, ensure_object, ensure_platform_int, is_array_like, is_bool_dtype, is_complex_dtype, is_dict_like, is_extension_array_dtype, is_float, is_float_dtype, is_integer, is_integer_dtype, is_list_like, is_object_dtype, is_signed_integer_dtype, needs_i8_conversion
  from pandas.core.dtypes.concat import concat_compat
  from pandas.core.dtypes.dtypes import BaseMaskedDtype, CategoricalDtype, ExtensionDtype, NumpyEADtype
  from pandas.core.dtypes.generic import ABCDatetimeArray, ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries, ABCTimedeltaArray
  from pandas.core.dtypes.missing import isna, na_value_for_dtype
  from pandas.core.array_algos.take import take_nd
  from pandas.core.construction import array, ensure_wrapped_if_datetimelike, extract_array
  from pandas.core.indexers import validate_indices
label_desc: Use image node_id 19 for calling a global function with example usage: searchsorted(arr, value, side, sorter) and returns: arr