if not isinstance(indices, np.ndarray):
indices = np.asarray(indices, dtype=np.int)
indices = nn.Variable.from_numpy_array(indices)
if shape is None and out is None:
raise TypeError("One of `shape` or `out` argument must be supplied.")
if shape and out:
raise TypeError("Only one of `shape` or `out` argument may be used.")
if out:
if isinstance(out, nn.Variable):
out = out.data
if not isinstance(out, nn.NdArray):
raise TypeError("`out` argument must be NdArray or Variable type.")
shape = out.shape
outputs = [out]
else:
if isinstance(shape, np.ndarray):
shape = shape.tolist()
outputs = None
return scatter_nd_base(data, indices, shape, outputs=outputs)