parameters: (cls, wt_init, num_wts, num_shards, name)
return_statement: return sharded_weight
docstring: Helper function to create sharded weight vector.
  
      Args:
        wt_init: init value for the weight. If None, weights are not created. This
          can be one of the None, a list of non-negative real numbers or a single
          non-negative real number (or equivalent iterables).
        num_wts: total size of all the weight shards
        num_shards: number of shards for the weights
        name: name for the new Variables.
  
      Returns:
        A list of weight shard Tensors.
  
      Raises:
        ValueError: If wt_init is not the right format.
docstring_summary: Helper function to create sharded weight vector.
docstring_tokens: Helper function to create sharded weight vector .
function: def _create_weights(cls, wt_init, num_wts, num_shards, name):
      """Helper function to create sharded weight vector.
  
      Args:
        wt_init: init value for the weight. If None, weights are not created. This
          can be one of the None, a list of non-negative real numbers or a single
          non-negative real number (or equivalent iterables).
        num_wts: total size of all the weight shards
        num_shards: number of shards for the weights
        name: name for the new Variables.
  
      Returns:
        A list of weight shard Tensors.
  
      Raises:
        ValueError: If wt_init is not the right format.
      """
  
      if wt_init is None:
        return None
  
      init_mode = "list"
      if isinstance(wt_init, collections_abc.Iterable):
        if num_shards == 1 and len(wt_init) == num_wts:
          wt_init = [wt_init]
        assert len(wt_init) == num_shards
      elif isinstance(wt_init, numbers.Real) and wt_init >= 0:
        init_mode = "scalar"
      else:
        raise ValueError(
            "Invalid weight initialization argument. Must be one of these: "
            "None, a real non-negative real number, or a list of lists of "
            "non-negative real numbers (or equivalent iterables) corresponding "
            "to sharded factors.")
  
      sizes = cls._shard_sizes(num_wts, num_shards)
      assert len(sizes) == num_shards
  
      def make_wt_initializer(i, size):
  
        def initializer():
          if init_mode == "scalar":
            return wt_init * array_ops.ones([size])
          else:
            return wt_init[i]
  
        return initializer
  
      sharded_weight = []
      for i, size in enumerate(sizes):
        var_name = "%s_shard_%d" % (name, i)
        var_init = make_wt_initializer(i, size)
        sharded_weight.append(
            variable_scope.variable(
                var_init, dtype=dtypes.float32, name=var_name))
  
      return sharded_weight
function_tokens: def _create_weights ( cls , wt_init , num_wts , num_shards , name ) : if wt_init is None : return None init_mode = "list" if isinstance ( wt_init , collections_abc . Iterable ) : if num_shards == 1 and len ( wt_init ) == num_wts : wt_init = [ wt_init ] assert len ( wt_init ) == num_shards elif isinstance ( wt_init , numbers . Real ) and wt_init >= 0 : init_mode = "scalar" else : raise ValueError ( "Invalid weight initialization argument. Must be one of these: " "None, a real non-negative real number, or a list of lists of " "non-negative real numbers (or equivalent iterables) corresponding " "to sharded factors." ) sizes = cls . _shard_sizes ( num_wts , num_shards ) assert len ( sizes ) == num_shards def make_wt_initializer ( i , size ) : def initializer ( ) : if init_mode == "scalar" : return wt_init * array_ops . ones ( [ size ] ) else : return wt_init [ i ] return initializer sharded_weight = [ ] for i , size in enumerate ( sizes ) : var_name = "%s_shard_%d" % ( name , i ) var_init = make_wt_initializer ( i , size ) sharded_weight . append ( variable_scope . variable ( var_init , dtype = dtypes . float32 , name = var_name ) ) return sharded_weight