parameters: (inputs, states)
return_statement: return (length, key, sorted_states, sorted_sequences, sorted_context)
docstring: Convert input to tensors and validate shape information.
  
    Args:
      inputs: A `_SequenceInputWrapper` instance.
      states: A dictionary mapping state names to input constants or tensors.
  
    Returns:
      The tuple (length, key, sorted_states, sorted_sequences, sorted_context),
      where each value has been checked for valid shape, and the sorted_* dicts
      are instances of OrderedDict; with key-value pairs sorted by key.
  
    Raises:
      ValueError: if the shapes of inputs.context.values(), states.values(),
        or inputs.sequences.values() are not fully defined (with the exception
        of the dimension of any `Tensor` in inputs.sequences.values()).
      TypeError: if the dtype of length is not int32.
docstring_summary: Convert input to tensors and validate shape information.
docstring_tokens: Convert input to tensors and validate shape information .
function: def _prepare_sequence_inputs(inputs, states):
    """Convert input to tensors and validate shape information.
  
    Args:
      inputs: A `_SequenceInputWrapper` instance.
      states: A dictionary mapping state names to input constants or tensors.
  
    Returns:
      The tuple (length, key, sorted_states, sorted_sequences, sorted_context),
      where each value has been checked for valid shape, and the sorted_* dicts
      are instances of OrderedDict; with key-value pairs sorted by key.
  
    Raises:
      ValueError: if the shapes of inputs.context.values(), states.values(),
        or inputs.sequences.values() are not fully defined (with the exception
        of the dimension of any `Tensor` in inputs.sequences.values()).
      TypeError: if the dtype of length is not int32.
    """
    # Convert state initial values to tensors
    states = dict((k, ops.convert_to_tensor(
        v, name="state_%s" % k)) for k, v in states.items())
  
    def _assert_fully_defined(label, dict_, ignore_first_dimension=False):
      start_dimension = 1 if ignore_first_dimension else 0
      for k, v in dict_.items():
        if not v.get_shape()[start_dimension:].is_fully_defined():
          raise ValueError("Shape for %s %s is not fully defined %s: %s" %
                           (label, k, "(ignoring first dimension)" if
                            ignore_first_dimension else "", v.get_shape()))
  
    _assert_fully_defined("state", states)
    _assert_fully_defined("context", inputs.context)
    # Sequences' first dimension (time) may be variable
    _assert_fully_defined(
        "sequence", inputs.sequences, ignore_first_dimension=True)
  
    # Get dictionaries' dtypes ordered by name - ordering is important
    # when switching between dicts and tuples for passing to Barrier.
    def _sort_by_name(d):
      return collections.OrderedDict(sorted(d.items(), key=lambda k_v: k_v[0]))
  
    sorted_sequences = _sort_by_name(inputs.sequences)
    sorted_context = _sort_by_name(inputs.context)
    sorted_states = _sort_by_name(states)
  
    length = _check_rank(inputs.length, 0)
    key = _check_rank(inputs.key, 0)
  
    if length.dtype != dtypes.int32:
      raise TypeError("length dtype must be int32, but received: %s" %
                      length.dtype)
    if key.dtype != dtypes.string:
      raise TypeError("key dtype must be string, but received: %s" % key.dtype)
  
    return (length, key, sorted_states, sorted_sequences, sorted_context)
function_tokens: def _prepare_sequence_inputs ( inputs , states ) : # Convert state initial values to tensors states = dict ( ( k , ops . convert_to_tensor ( v , name = "state_%s" % k ) ) for k , v in states . items ( ) ) def _assert_fully_defined ( label , dict_ , ignore_first_dimension = False ) : start_dimension = 1 if ignore_first_dimension else 0 for k , v in dict_ . items ( ) : if not v . get_shape ( ) [ start_dimension : ] . is_fully_defined ( ) : raise ValueError ( "Shape for %s %s is not fully defined %s: %s" % ( label , k , "(ignoring first dimension)" if ignore_first_dimension else "" , v . get_shape ( ) ) ) _assert_fully_defined ( "state" , states ) _assert_fully_defined ( "context" , inputs . context ) # Sequences' first dimension (time) may be variable _assert_fully_defined ( "sequence" , inputs . sequences , ignore_first_dimension = True ) # Get dictionaries' dtypes ordered by name - ordering is important # when switching between dicts and tuples for passing to Barrier. def _sort_by_name ( d ) : return collections . OrderedDict ( sorted ( d . items ( ) , key = lambda k_v : k_v [ 0 ] ) ) sorted_sequences = _sort_by_name ( inputs . sequences ) sorted_context = _sort_by_name ( inputs . context ) sorted_states = _sort_by_name ( states ) length = _check_rank ( inputs . length , 0 ) key = _check_rank ( inputs . key , 0 ) if length . dtype != dtypes . int32 : raise TypeError ( "length dtype must be int32, but received: %s" % length . dtype ) if key . dtype != dtypes . string : raise TypeError ( "key dtype must be string, but received: %s" % key . dtype ) return ( length , key , sorted_states , sorted_sequences , sorted_context )