                      (< idx num-items))
               (let [next-max (long (rev-max-shape idx))
                     next-stride (long (rev-strides idx))
-                    next-dim (long (rev-shape idx))
+                    next-dim-entry (rev-shape idx)
+                    next-dim (disambiguate-shape-entry next-dim-entry)
                     max-idx (rem arg next-max)
                     shape-idx (rem arg next-dim)]
                 (recur (inc idx)
                        (quot arg next-max)
-                       (+ offset (* next-stride shape-idx))))
+                       (+ offset (* next-stride
+                                    (if (number? next-dim)
+                                      shape-idx
+                                      (long (m/mget next-dim
+                                                    shape-idx)))))))
               offset)))))
 
 

                    shapes)]
    {:max-shape (vec (apply map (fn [& args]
                                  (apply max 0 args))
                            shapes))
     :dimensions (mapv #(hash-map :shape %1 :strides %2) shapes strides)}))



    {:shape shape})
  (if (= 1 (count shape))
    [1 (first shape)]
    [(first shape) (apply * (ensure-direct-shape (drop 1 shape)))]))


(defn shape
  [{:keys [shape]}]
  (disambiguate-shape shape))


(defn strides
