code: def searchsorted(
      sorted_sequence, values, right=False, out_dtype="int64"
  ):
      """Find indices where elements should be inserted to maintain order.
         If `sorted_sequence` is N-dimensional, the innermost dimension of
         `values` are searched in the corresponding dimension of `sorted_sequence`.
  
      Parameters
      ----------
      sorted_sequence : te.Tensor
          N-D or 1-D Tensor, containing monotonically increasing sequence
          on the innermost dimension.
  
      values : te.Tensor
          N-D Tensor containing the search values. When `sorted_sequence` is 1-D,
          the shape of `values` can be arbitrary. Otherwise, ranks of `sorted_sequence`
          and `values` must be the same, and outer N-1 axes must have the same size.
  
      right : bool, optional
          Controls which index is returned if a value lands exactly on one of sorted values. If
          False, the index of the first suitable location found is given. If true, return the
          last such index. If there is no suitable index, return either 0 or N (where N is the
          size of the innermost dimension).
  
      dtype : string, optional
          The data type of the output indices.
  
      Returns
      -------
      indices : te.Tensor
          Tensor with same shape as values, representing the indices of
          elements of `values` if they are inserted in `sorted_sequence`.
      """
  
      def ir(sorted_sequence, values, indices):
          ib = ir_builder.create()
          sorted_sequence_shape = sorted_sequence.shape
          values_shape = values.shape
          num_search = utils.prod(values_shape)
          search_range = sorted_sequence_shape[-1]
  
          sorted_sequence = ib.buffer_ptr(sorted_sequence)
          values = ib.buffer_ptr(values)
          indices = ib.buffer_ptr(indices)
  
          with ib.for_range(
              0, num_search, name="i", kind="parallel"
          ) as i:
              if len(sorted_sequence_shape) == 1:
                  sequence_offset = 0
              else:
                  sequence_id = i // values_shape[-1]
                  sequence_offset = sequence_id * search_range
  
              indices[i] = binary_search(
                  ib,
                  sequence_offset,
                  search_range,
                  sorted_sequence,
                  values[i],
                  right,
                  out_dtype,
              )
  
          return ib.get()
  
      return te.extern(
          values.shape,
          [sorted_sequence, values],
          lambda ins, outs: ir(ins[0], ins[1], outs[0]),
          name="searchsorted",
          dtype=out_dtype,
      )
  
imports: from .None import utils
  from .None import te
  from ..tir import ir_builder
  from .math import cast
label_desc: Use image node_id 2 for calling a global function with example usage: searchsorted(sorted_sequence, values, right, out_dtype) and returns: te, ib