parameters: (input_vars, enter_vars, shapes)
docstring: Set the shapes of the tensors in `enter_vars` to `shapes`.
  
    Args:
      input_vars: A list of tensors that are inputs to `enter_vars`.
      enter_vars: A list of tensors whose shapes will be set.
      shapes: A (possibly nested) list of shapes.
  
    Raises:
      ValueError: If any tensor in `enter_vars` has a less specific shape
        than its corresponding shape in `shapes`.
docstring_summary: Set the shapes of the tensors in `enter_vars` to `shapes`.
docstring_tokens: Set the shapes of the tensors in enter_vars to shapes .
function: def _SetShapeInvariants(input_vars, enter_vars, shapes):
    """Set the shapes of the tensors in `enter_vars` to `shapes`.
  
    Args:
      input_vars: A list of tensors that are inputs to `enter_vars`.
      enter_vars: A list of tensors whose shapes will be set.
      shapes: A (possibly nested) list of shapes.
  
    Raises:
      ValueError: If any tensor in `enter_vars` has a less specific shape
        than its corresponding shape in `shapes`.
    """
    if shapes is None:
      return
    flat_shapes = nest.flatten(shapes)
    if not all([isinstance(s, tensor_shape.TensorShape) for s in flat_shapes]):
      raise ValueError("`shapes` must be a (possibly nested) list of shapes.")
    # Check that the shapes of the inputs are less than the shape invariants,
    # and set the shapes of `enter_vars` to the shape invariants.
    for inp, var, shape in zip(input_vars, enter_vars, flat_shapes):
      if isinstance(var, ops.Tensor):
        if not _ShapeLessThanOrEqual(inp.get_shape(), shape):
          raise ValueError(
              "The shape invariant specified for %s is not compatible with "
              "the initial shape of the loop variable. It enters the loop "
              "with shape %s, but the specified shape invariant is %s."
              % (inp.name, inp.get_shape(), shape))
        var.set_shape(shape)
      else:
        if not isinstance(var, (ops.IndexedSlices, sparse_tensor.SparseTensor)):
          raise TypeError("Type %s not supported" % type(var))
        if isinstance(var, ops.IndexedSlices):
          if not _ShapeLessThanOrEqual(inp.values.get_shape(), shape):
            raise ValueError(
                "The shape invariant specified for %s is not compatible with "
                "the initial shape of the values tensor of this IndexedSlices. "
                "It enters the loop with shape %s, but the specified shape "
                "invariant is %s."
                % (inp.values.name, inp.values.get_shape(), shape))
          var.values.set_shape(shape)
          var.indices.set_shape(tensor_shape.TensorShape([shape[0]]))
          if var.dense_shape is not None:
            var.dense_shape.set_shape(tensor_shape.TensorShape([shape.ndims]))
        else:
          if not _ShapeLessThanOrEqual(inp.dense_shape.get_shape(), shape):
            raise ValueError(
                "The shape invariant specified for %s is not compatible with "
                "the initial shape of the shape tensor of this SparseTensor. "
                "It enters the loop with shape %s, but the specified shape "
                "invariant is %s."
                % (inp.dense_shape.name, inp.dense_shape.get_shape(), shape))
          var.values.set_shape(tensor_shape.TensorShape([None]))
          var.indices.set_shape(tensor_shape.TensorShape([None, shape.ndims]))
          var.dense_shape.set_shape(shape)
function_tokens: def _SetShapeInvariants ( input_vars , enter_vars , shapes ) : if shapes is None : return flat_shapes = nest . flatten ( shapes ) if not all ( [ isinstance ( s , tensor_shape . TensorShape ) for s in flat_shapes ] ) : raise ValueError ( "`shapes` must be a (possibly nested) list of shapes." ) # Check that the shapes of the inputs are less than the shape invariants, # and set the shapes of `enter_vars` to the shape invariants. for inp , var , shape in zip ( input_vars , enter_vars , flat_shapes ) : if isinstance ( var , ops . Tensor ) : if not _ShapeLessThanOrEqual ( inp . get_shape ( ) , shape ) : raise ValueError ( "The shape invariant specified for %s is not compatible with " "the initial shape of the loop variable. It enters the loop " "with shape %s, but the specified shape invariant is %s." % ( inp . name , inp . get_shape ( ) , shape ) ) var . set_shape ( shape ) else : if not isinstance ( var , ( ops . IndexedSlices , sparse_tensor . SparseTensor ) ) : raise TypeError ( "Type %s not supported" % type ( var ) ) if isinstance ( var , ops . IndexedSlices ) : if not _ShapeLessThanOrEqual ( inp . values . get_shape ( ) , shape ) : raise ValueError ( "The shape invariant specified for %s is not compatible with " "the initial shape of the values tensor of this IndexedSlices. " "It enters the loop with shape %s, but the specified shape " "invariant is %s." % ( inp . values . name , inp . values . get_shape ( ) , shape ) ) var . values . set_shape ( shape ) var . indices . set_shape ( tensor_shape . TensorShape ( [ shape [ 0 ] ] ) ) if var . dense_shape is not None : var . dense_shape . set_shape ( tensor_shape . TensorShape ( [ shape . ndims ] ) ) else : if not _ShapeLessThanOrEqual ( inp . dense_shape . get_shape ( ) , shape ) : raise ValueError ( "The shape invariant specified for %s is not compatible with " "the initial shape of the shape tensor of this SparseTensor. " "It enters the loop with shape %s, but the specified shape " "invariant is %s." % ( inp . dense_shape . name , inp . dense_shape . get_shape ( ) , shape ) ) var . values . set_shape ( tensor_shape . TensorShape ( [ None ] ) ) var . indices . set_shape ( tensor_shape . TensorShape ( [ None , shape . ndims ] ) ) var . dense_shape . set_shape ( shape )