code: def _simplify_shape(self, alist, rec=0):
          
          if rec != 0:
              if len(alist) == 1:
                  return alist[-1]
              return alist
          if len(alist) == 1:
              return self._simplify_shape(alist[-1], 1)
          return [self._simplify_shape(al, 1) for al in alist]
docs: Reduce the alist dimension if needed