parameters: (tensor, num_epochs=None, name=None)
docstring: Returns tensor `num_epochs` times and then raises an `OutOfRange` error.
  
    Args:
      tensor: Any `Tensor`.
      num_epochs: A positive integer (optional).  If specified, limits the number
        of steps the output tensor may be evaluated.
      name: A name for the operations (optional).
  
    Returns:
      tensor or `OutOfRange`.
  
    Raises:
      ValueError: if `num_epochs` is invalid.
docstring_summary: Returns tensor `num_epochs` times and then raises an `OutOfRange` error.
docstring_tokens: Returns tensor num_epochs times and then raises an OutOfRange error .
function: def limit_epochs(tensor, num_epochs=None, name=None):
    """Returns tensor `num_epochs` times and then raises an `OutOfRange` error.
  
    Args:
      tensor: Any `Tensor`.
      num_epochs: A positive integer (optional).  If specified, limits the number
        of steps the output tensor may be evaluated.
      name: A name for the operations (optional).
  
    Returns:
      tensor or `OutOfRange`.
  
    Raises:
      ValueError: if `num_epochs` is invalid.
    """
    if num_epochs is None:
      return tensor
    if num_epochs <= 0:
      raise ValueError("num_epochs must be > 0 not %d." % num_epochs)
    with ops.op_scope([tensor], name, "limit_epochs") as name:
      zero64 = constant_op.constant(0, dtype=dtypes.int64)
      epochs = variables.Variable(
          zero64, name="epochs", trainable=False,
          collections=[ops.GraphKeys.LOCAL_VARIABLES])
      counter = epochs.count_up_to(num_epochs)
      with ops.control_dependencies([counter]):
        return array_ops.identity(tensor, name=name)
function_tokens: def limit_epochs ( tensor , num_epochs = None , name = None ) : if num_epochs is None : return tensor if num_epochs <= 0 : raise ValueError ( "num_epochs must be > 0 not %d." % num_epochs ) with ops . op_scope ( [ tensor ] , name , "limit_epochs" ) as name : zero64 = constant_op . constant ( 0 , dtype = dtypes . int64 ) epochs = variables . Variable ( zero64 , name = "epochs" , trainable = False , collections = [ ops . GraphKeys . LOCAL_VARIABLES ] ) counter = epochs . count_up_to ( num_epochs ) with ops . control_dependencies ( [ counter ] ) : return array_ops . identity ( tensor , name = name )