parameters: (list_or_tuple, dtype, name)
docstring: Converts the given list or tuple to a tensor by packing.
  
    Args:
      list_or_tuple: A (possibly nested) list or tuple containing a tensor.
      dtype: The element type of the returned tensor.
      name: A name for the returned tensor.
  
    Returns:
      A `tf.Tensor` with value equivalent to `list_or_tuple`.
docstring_summary: Converts the given list or tuple to a tensor by packing.
docstring_tokens: Converts the given list or tuple to a tensor by packing .
function: def _autopacking_helper(list_or_tuple, dtype, name):
    """Converts the given list or tuple to a tensor by packing.
  
    Args:
      list_or_tuple: A (possibly nested) list or tuple containing a tensor.
      dtype: The element type of the returned tensor.
      name: A name for the returned tensor.
  
    Returns:
      A `tf.Tensor` with value equivalent to `list_or_tuple`.
    """
    must_pack = False
    converted_elems = []
    with ops.name_scope(name) as scope:
      for i, elem in enumerate(list_or_tuple):
        if ops.is_dense_tensor_like(elem):
          if dtype is not None and elem.dtype.base_dtype != dtype:
            raise TypeError(
                "Cannot convert a list containing a tensor of dtype "
                "%s to %s (Tensor is: %r)" % (elem.dtype, dtype, elem))
          converted_elems.append(elem)
          must_pack = True
        elif isinstance(elem, (list, tuple)):
          converted_elem = _autopacking_helper(elem, dtype, str(i))
          if ops.is_dense_tensor_like(converted_elem):
            must_pack = True
          converted_elems.append(converted_elem)
        else:
          converted_elems.append(elem)
      if must_pack:
        elems_as_tensors = []
        for i, elem in enumerate(converted_elems):
          if ops.is_dense_tensor_like(elem):
            elems_as_tensors.append(elem)
          else:
            # NOTE(mrry): This is inefficient, but it enables us to
            # handle the case where the list arguments are other
            # convertible-to-tensor types, such as numpy arrays.
            elems_as_tensors.append(
                constant_op.constant(elem, dtype=dtype, name=str(i)))
        return gen_array_ops._pack(elems_as_tensors, name=scope)
      else:
        return converted_elems
function_tokens: def _autopacking_helper ( list_or_tuple , dtype , name ) : must_pack = False converted_elems = [ ] with ops . name_scope ( name ) as scope : for i , elem in enumerate ( list_or_tuple ) : if ops . is_dense_tensor_like ( elem ) : if dtype is not None and elem . dtype . base_dtype != dtype : raise TypeError ( "Cannot convert a list containing a tensor of dtype " "%s to %s (Tensor is: %r)" % ( elem . dtype , dtype , elem ) ) converted_elems . append ( elem ) must_pack = True elif isinstance ( elem , ( list , tuple ) ) : converted_elem = _autopacking_helper ( elem , dtype , str ( i ) ) if ops . is_dense_tensor_like ( converted_elem ) : must_pack = True converted_elems . append ( converted_elem ) else : converted_elems . append ( elem ) if must_pack : elems_as_tensors = [ ] for i , elem in enumerate ( converted_elems ) : if ops . is_dense_tensor_like ( elem ) : elems_as_tensors . append ( elem ) else : # NOTE(mrry): This is inefficient, but it enables us to # handle the case where the list arguments are other # convertible-to-tensor types, such as numpy arrays. elems_as_tensors . append ( constant_op . constant ( elem , dtype = dtype , name = str ( i ) ) ) return gen_array_ops . _pack ( elems_as_tensors , name = scope ) else : return converted_elems