code: def from_list(
      lst: List[Any],
      name: Optional[str] = None,
      dtype: Optional[int] = None,
  ) -> SequenceProto:
      """Converts a list into a sequence def.
  
      Args:
          lst: a Python list
          name: (optional) the name of the sequence.
          dtype: (optional) type of element in the input list, used for specifying
                            sequence values when converting an empty list.
  
      Returns:
          SequenceProto: the converted sequence def.
      """
      sequence = SequenceProto()
      if name:
          sequence.name = name
  
      if dtype:
          elem_type = dtype
      elif len(lst) > 0:
          first_elem = lst[0]
          if isinstance(first_elem, dict):
              elem_type = SequenceProto.MAP
          elif isinstance(first_elem, list):
              elem_type = SequenceProto.SEQUENCE
          else:
              elem_type = SequenceProto.TENSOR
      else:
          # if empty input list and no dtype specified
          # choose sequence of tensors on default
          elem_type = SequenceProto.TENSOR
      sequence.elem_type = elem_type
  
      if (len(lst) > 0) and not all(
          isinstance(elem, type(lst[0])) for elem in lst
      ):
          raise TypeError(
              "The element type in the input list is not the same "
              "for all elements and therefore is not supported as a sequence."
          )
  
      if elem_type == SequenceProto.TENSOR:
          for tensor in lst:
              sequence.tensor_values.extend([from_array(tensor)])
      elif elem_type == SequenceProto.SEQUENCE:
          for seq in lst:
              sequence.sequence_values.extend([from_list(seq)])
      elif elem_type == SequenceProto.MAP:
          for mapping in lst:
              sequence.map_values.extend([from_dict(mapping)])
      else:
          raise TypeError(
              "The element type in the input list is not a tensor, "
              "sequence, or map and is not supported."
          )
      return sequence
  
imports: import sys
  from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
  import numpy
  from onnx import MapProto, OptionalProto, SequenceProto, TensorProto, helper, subbyte
  from onnx.external_data_helper import load_external_data_for_tensor, uses_external_data
label_desc: Use image node_id 11 for calling a global function with example usage: from_list(lst, name, dtype) and returns: sequence