code: def setitem_on_chunk_to_records(
      nsplits_acc, output_chunk, value, ts, is_scalar
  ):
      """
      Turns a `__setitem__` on chunk to a list of index-value records.
  
      Parameters
      ----------
      nsplits_acc:
          Accumulate nsplits arrays of the output tensor chunks.
  
      Returns
      -------
          A list of `(index, value, timestamp)`, where `index` is the in-chunk index.
      """
      input_indices, value_indices = indexing_to_chunk_indices(
          output_chunk
      )
  
      # normalize assigned value
      if is_scalar:
          chunk_value = value
      else:
          chunk_value_slice = tuple(
              slice(
                  nsplits_acc[i][output_chunk.index[i]],
                  nsplits_acc[i][output_chunk.index[i] + 1],
              )
              for i in range(len(output_chunk.index))
          )
          chunk_value = value[chunk_value_slice]
  
      records = []
      for chunk_idx, value_idx in zip(
          itertools.product(*input_indices),
          itertools.product(*value_indices),
      ):
          new_value = (
              chunk_value if is_scalar else chunk_value[value_idx]
          )
          index_in_chunk = np.ravel_multi_index(
              chunk_idx, output_chunk.op.inputs[0].shape
          )
          records.append((index_in_chunk, new_value, ts))
      return records
  
file_path: mars/mars/services/mutable/utils.py
imports: from datetime import datetime
  import itertools
  from numbers import Integral
  from typing import Optional
  import uuid
  import numpy
  from ...core import tile
label_desc: Use image node_id 3 for calling a global function with example usage: setitem_on_chunk_to_records(nsplits_acc, output_chunk, value, ts, is_scalar) and returns: records