class_docstr: Flat iterator object to iterate over arrays.
  
  A flatiter iterator is returned by ``x.flat`` for any array ``x``. It
  allows iterating over the array as if it were a 1-D array, either in a
  for-loop or by calling its ``next`` method.
  
  Iteration is done in row-major, C-style order (the last index varying the
  fastest).
  
  Attributes:
      base (cupy.ndarray): A reference to the array that is iterated over.
  
  .. note::
     Restricted support of basic slicing is currently supplied. Advanced
     indexing is not supported yet.
  
  .. seealso:: :func:`numpy.flatiter`
class_docstr_tok: ["Flat","iterator","object","to","iterate","over","arrays",".","A","flatiter","iterator","is","returned","by","``","x.flat","``","for","any","array","``","x","``",".","It","allows","iterating","over","the","array","as","if","it","were","a","1-D","array",",","either","in","a","for-loop","or","by","calling","its","``","next","``","method",".","Iteration","is","done","in","row-major",",","C-style","order","(","the","last","index","varying","the","fastest",")",".","Attributes",":","base","(","cupy.ndarray",")",":","A","reference","to","the","array","that","is","iterated","over",".","..","note",":",":","Restricted","support","of","basic","slicing","is","currently","supplied",".","Advanced","indexing","is","not","supported","yet",".","..","seealso",":",":",":","func",":","`","numpy.flatiter","`"]
code: def __setitem__(self, ind, value):
      if ind is Ellipsis:
          self[:] = value
          return
  
      if isinstance(ind, tuple):
          raise IndexError("unsupported iterator index")
  
      if isinstance(ind, bool):
          raise IndexError("unsupported iterator index")
  
      if numpy.isscalar(ind):
          ind = int(ind)
          base = self._base
          size = base.size
          indices = []
          for s in base.shape:
              size = size // s
              indices.append(ind // size)
              ind %= size
          base[tuple(indices)] = value
          return
  
      if isinstance(ind, slice):
          base = self._base
          s = internal.complete_slice(ind, base.size)
          s_start = s.start
          s_step = s.step
          size = s.stop - s.start
          if s_step > 0:
              size = (size - 1) // s_step + 1
          else:
              size = (size + 1) // s_step + 1
          value = cupy.asarray(value, dtype=base.dtype)
          _flatiter_setitem_slice(
              value, s_start, s_step, base, size=size
          )
          return
  
      raise IndexError("unsupported iterator index")
  
file_path: cupy/cupy/_indexing/iterate.py
imports: import numpy
  import cupy
  from cupy import _core
  from cupy._core import internal
label_desc: Use image node_id 2 for calling the flatiter obj's underlying member method code with example usage: obj.__setitem__(ind, value) without return types