parameters: (shape, dtype=dtypes.float32, name=None)
return_statement: return output
docstring: Creates a tensor with all elements set to 1.
  
    This operation returns a tensor of type `dtype` with shape `shape` and all
    elements set to 1.
  
    For example:
  
    ```python
    tf.ones([2, 3], tf.int32)  # [[1, 1, 1], [1, 1, 1]]
    ```
  
    Args:
      shape: A list of integers, a tuple of integers, or a 1-D `Tensor` of type
        `int32`.
      dtype: The type of an element in the resulting `Tensor`.
      name: A name for the operation (optional).
  
    Returns:
      A `Tensor` with all elements set to 1.
docstring_summary: Creates a tensor with all elements set to 1.
docstring_tokens: Creates a tensor with all elements set to 1 .
function: def ones(shape, dtype=dtypes.float32, name=None):
    """Creates a tensor with all elements set to 1.
  
    This operation returns a tensor of type `dtype` with shape `shape` and all
    elements set to 1.
  
    For example:
  
    ```python
    tf.ones([2, 3], tf.int32)  # [[1, 1, 1], [1, 1, 1]]
    ```
  
    Args:
      shape: A list of integers, a tuple of integers, or a 1-D `Tensor` of type
        `int32`.
      dtype: The type of an element in the resulting `Tensor`.
      name: A name for the operation (optional).
  
    Returns:
      A `Tensor` with all elements set to 1.
    """
    dtype = dtypes.as_dtype(dtype).base_dtype
    with ops.name_scope(name, "ones", [shape]) as name:
      one = True if dtype == dtypes.bool else 1
      if not isinstance(shape, ops.Tensor):
        try:
          # Create a constant if it won't be very big. Otherwise create a fill op
          # to prevent serialized GraphDefs from becoming too large.
          output = _constant_if_small(one, shape, dtype, name)
          if output is not None:
            return output
  
          # Go through tensor shapes to get int64-if-needed semantics
          shape = constant_op._tensor_shape_tensor_conversion_function(
              tensor_shape.TensorShape(shape))
        except (TypeError, ValueError):
          # Happens when shape is a list with tensor elements
          shape = ops.convert_to_tensor(shape, dtype=dtypes.int32)
      if not shape._shape_tuple():
        shape = reshape(shape, [-1])  # Ensure it's a vector
      output = fill(shape, constant(one, dtype=dtype), name=name)
    assert output.dtype.base_dtype == dtype
    return output
function_tokens: def ones ( shape , dtype = dtypes . float32 , name = None ) : dtype = dtypes . as_dtype ( dtype ) . base_dtype with ops . name_scope ( name , "ones" , [ shape ] ) as name : one = True if dtype == dtypes . bool else 1 if not isinstance ( shape , ops . Tensor ) : try : # Create a constant if it won't be very big. Otherwise create a fill op # to prevent serialized GraphDefs from becoming too large. output = _constant_if_small ( one , shape , dtype , name ) if output is not None : return output # Go through tensor shapes to get int64-if-needed semantics shape = constant_op . _tensor_shape_tensor_conversion_function ( tensor_shape . TensorShape ( shape ) ) except ( TypeError , ValueError ) : # Happens when shape is a list with tensor elements shape = ops . convert_to_tensor ( shape , dtype = dtypes . int32 ) if not shape . _shape_tuple ( ) : shape = reshape ( shape , [ - 1 ] ) # Ensure it's a vector output = fill ( shape , constant ( one , dtype = dtype ) , name = name ) assert output . dtype . base_dtype == dtype return output