docs: def vector_to_arr(vec, dim):
      """Reshape a vector to a multidimensional array with dimensions 'dim'.
      """
      if len(dim) <= 1:
          return vec
      array = vec
      while len(dim) > 1:
          i = 0
          outer_array = []
          for m in range(reduce(mul, dim[0:-1])):
              inner_array = []
              for n in range(dim[-1]):
                  inner_array.append(array[i])
                  i += 1
              outer_array.append(inner_array)
          array = outer_array
          dim = dim[0:-1]
  
          return array