code: def _dims2shape(*dims):
      
      if not dims:
          raise ValueError("expected at least one dimension spec")
      shape = list()
      for dim in dims:
          if isinstance(dim, int):
              dim = (0, dim)
          if isinstance(dim, tuple) and len(dim) == 2:
              if dim[0] < 0:
                  raise ValueError("expected low dimension to be >= 0")
              if dim[1] < 0:
                  raise ValueError("expected high dimension to be >= 0")
              if dim[0] > dim[1]:
                  raise ValueError("expected low <= high dimensions")
              start, stop = dim
          else:
              raise TypeError("expected dimension to be int or (int, int)")
          shape.append((start, stop))
      return tuple(shape)
docs: Convert input dimensions to a shape.