parameters: (*args, **kwargs)
return_statement: return ts
docstring: Helper to select tensors.
  
    Args:
      *args: list of 1) regular expressions (compiled or not) or 2) (array of)
        `tf.Tensor`. `tf.Operation` instances are silently ignored.
      **kwargs: 'graph': `tf.Graph` in which to perform the regex query.This is
        required when using regex.
        'positive_filter': an elem if selected only if `positive_filter(elem)` is
          `True`. This is optional.
        'restrict_ts_regex': a regular expression is ignored if it doesn't start
          with the substring "(?#ts)".
    Returns:
      A list of `tf.Tensor`.
    Raises:
      TypeError: if the optional keyword argument graph is not a `tf.Graph`
        or if an argument in args is not an (array of) `tf.Tensor`
        or an (array of) `tf.Operation` (silently ignored) or a string
        or a regular expression.
      ValueError: if one of the keyword arguments is unexpected or if a regular
        expression is used without passing a graph as a keyword argument.
docstring_summary: Helper to select tensors.
docstring_tokens: Helper to select tensors .
function: def select_ts(*args, **kwargs):
    """Helper to select tensors.
  
    Args:
      *args: list of 1) regular expressions (compiled or not) or 2) (array of)
        `tf.Tensor`. `tf.Operation` instances are silently ignored.
      **kwargs: 'graph': `tf.Graph` in which to perform the regex query.This is
        required when using regex.
        'positive_filter': an elem if selected only if `positive_filter(elem)` is
          `True`. This is optional.
        'restrict_ts_regex': a regular expression is ignored if it doesn't start
          with the substring "(?#ts)".
    Returns:
      A list of `tf.Tensor`.
    Raises:
      TypeError: if the optional keyword argument graph is not a `tf.Graph`
        or if an argument in args is not an (array of) `tf.Tensor`
        or an (array of) `tf.Operation` (silently ignored) or a string
        or a regular expression.
      ValueError: if one of the keyword arguments is unexpected or if a regular
        expression is used without passing a graph as a keyword argument.
    """
    # get keywords arguments
    graph = None
    positive_filter = None
    restrict_ts_regex = False
    for k, v in iteritems(kwargs):
      if k == "graph":
        graph = v
        if graph is not None and not isinstance(graph, tf_ops.Graph):
          raise TypeError("Expected a tf.Graph, got {}".format(type(graph)))
      elif k == "positive_filter":
        positive_filter = v
      elif k == "restrict_ts_regex":
        restrict_ts_regex = v
      elif k == "restrict_ops_regex":
        pass
      else:
        raise ValueError("Wrong keywords argument: {}.".format(k))
  
    ts = []
  
    for arg in args:
      if can_be_regex(arg):
        if graph is None:
          raise ValueError("Use the keyword argument 'graph' to use regex.")
        regex = make_regex(arg)
        if regex.pattern.startswith("(?#ops)"):
          continue
        if restrict_ts_regex and not regex.pattern.startswith("(?#ts)"):
          continue
        ts_ = filter_ts_from_regex(graph, regex)
        for t_ in ts_:
          if t_ not in ts:
            if positive_filter is None or positive_filter(t_):
              ts.append(t_)
      else:
        ts_aux = util.make_list_of_t(arg, ignore_ops=True)
        if positive_filter is not None:
          ts_aux = [t for t in ts_aux if positive_filter(t)]
        ts_aux = [t for t in ts_aux if t not in ts]
        ts += ts_aux
  
    return ts
function_tokens: def select_ts ( * args , * * kwargs ) : # get keywords arguments graph = None positive_filter = None restrict_ts_regex = False for k , v in iteritems ( kwargs ) : if k == "graph" : graph = v if graph is not None and not isinstance ( graph , tf_ops . Graph ) : raise TypeError ( "Expected a tf.Graph, got {}" . format ( type ( graph ) ) ) elif k == "positive_filter" : positive_filter = v elif k == "restrict_ts_regex" : restrict_ts_regex = v elif k == "restrict_ops_regex" : pass else : raise ValueError ( "Wrong keywords argument: {}." . format ( k ) ) ts = [ ] for arg in args : if can_be_regex ( arg ) : if graph is None : raise ValueError ( "Use the keyword argument 'graph' to use regex." ) regex = make_regex ( arg ) if regex . pattern . startswith ( "(?#ops)" ) : continue if restrict_ts_regex and not regex . pattern . startswith ( "(?#ts)" ) : continue ts_ = filter_ts_from_regex ( graph , regex ) for t_ in ts_ : if t_ not in ts : if positive_filter is None or positive_filter ( t_ ) : ts . append ( t_ ) else : ts_aux = util . make_list_of_t ( arg , ignore_ops = True ) if positive_filter is not None : ts_aux = [ t for t in ts_aux if positive_filter ( t ) ] ts_aux = [ t for t in ts_aux if t not in ts ] ts += ts_aux return ts