code: def _prepare_index_for_memoryview(i, j, x=None):
      """
      Convert index and data arrays to form suitable for passing to the
      Cython fancy getset routines.
  
      The conversions are necessary since to (i) ensure the integer
      index arrays are in one of the accepted types, and (ii) to ensure
      the arrays are writable so that Cython memoryview support doesn't
      choke on them.
  
      Parameters
      ----------
      i, j
          Index arrays
      x : optional
          Data arrays
  
      Returns
      -------
      i, j, x
          Re-formatted arrays (x is omitted, if input was None)
  
      """
      if i.dtype > j.dtype:
          j = j.astype(i.dtype)
      elif i.dtype < j.dtype:
          i = i.astype(j.dtype)
  
      if not i.flags.writeable or i.dtype not in (np.int32, np.int64):
          i = i.astype(np.intp)
      if not j.flags.writeable or j.dtype not in (np.int32, np.int64):
          j = j.astype(np.intp)
  
      if x is not None:
          if not x.flags.writeable:
              x = x.copy()
          return i, j, x
      else:
          return i, j
  
imports: from __future__ import division, print_function, absolute_import
  from bisect import bisect_left
  import numpy
  from scipy._lib._version import NumpyVersion
  from scipy._lib.six import xrange, zip
  from .base import spmatrix, isspmatrix
  from .sputils import getdtype, isshape, isscalarlike, IndexMixin, upcast_scalar, get_index_dtype, isintlike, check_shape, check_reshape_kwargs, asmatrix
  from .None import _csparsetools
label_desc: Use image node_id 1 for calling a global function with example usage: _prepare_index_for_memoryview(i, j, x) and returns: i,  j,  x, i,  j