def strides(shape):
  """Computes ndarray.strides for an array shape."""
  result = []
  stride = 1
  for _, x in reversed(list(enumerate(shape))):
    result.append(stride)
    stride *= x
  return list(reversed(result))