code: def random_weights(size, sumto=1.0):
      
  
      w = np.random.random(size)
      if w.ndim == 2:
          if isinstance(sumto, (np.ndarray, list, tuple)):
              sumto = np.asarray(sumto)[:, None]
          w = sumto * w / w.sum(axis=-1)[:, None]
      elif w.ndim == 1:
          w = sumto * w / w.sum()
      else:
          raise ValueError("`w.ndim` must be 1 or 2, not %s" % w.ndim)
      return w
docs: Generate an array of random weights that sum to `sumto`.
  
      The result may be of arbitrary dimensions.  `size` is passed to
      the `size` parameter of `np.random.random`, which acts as a shape
      parameter in this case.
  
      Note that `sumto` is subject to typical Python floating point limitations.
      This function does not implement a softmax check.
  
      Parameters
      ----------
      size: int or tuple of ints, optional
          Output shape.  If the given shape is, e.g., ``(m, n, k)``, then
          ``m * n * k`` samples are drawn.
      sumto: float, default 1.
          Each vector of weights should sum to this in decimal terms.
  
      Returns
      -------
      np.ndarray