code: def _to_tensor_list_helper(encode_fn, element_spec, element):
      """Returns a tensor list representation of the element.
  
      Args:
        encode_fn: Method that constructs a tensor list representation from the
          given element spec and element.
        element_spec: A nested structure of `tf.TypeSpec` objects representing to
          element type specification.
        element: The element to convert to tensor list representation.
  
      Returns:
        A tensor list representation of `element`.
  
      Raises:
        ValueError: If `element_spec` and `element` do not have the same number of
          elements or if the two structures are not nested in the same way.
        TypeError: If `element_spec` and `element` differ in the type of sequence
          in any of their substructures.
      """
  
      nest.assert_same_structure(element_spec, element)
  
      def reduce_fn(state, value):
          spec, component = value
          if isinstance(spec, internal.TensorSpec):
              try:
                  component = ops.convert_to_tensor(
                      component, spec.dtype
                  )
              except (TypeError, ValueError):
                  raise ValueError(
                      f"Value {component} is not convertible to a tensor with "
                      f"dtype {spec.dtype} and shape {spec.shape}."
                  )
              if not component.shape.is_compatible_with(spec.shape):
                  raise ValueError(
                      f"Value {component} is not convertible to a tensor with "
                      f"dtype {spec.dtype} and shape {spec.shape}."
                  )
          return encode_fn(state, spec, component)
  
      return functools.reduce(
          reduce_fn,
          zip(nest.flatten(element_spec), nest.flatten(element)),
          [],
      )
  
imports: import collections
  import functools
  import itertools
  import wrapt
  from tensorflow.python.data.util import nest
  from tensorflow.python.framework import composite_tensor
  from tensorflow.python.framework import none_tensor
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import type_spec
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import internal
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.compat import collections_abc
  from tensorflow.python.util.nest_util import CustomNestProtocol
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 13 for calling a global function with example usage: _to_tensor_list_helper(encode_fn, element_spec, element) and returns: functools, encode_fn