code: def from_regions(regions, contig_map=None):
      """Parses each region of `regions` into a Range proto.
  
      This function provides a super high-level interface for
      reading/parsing/converting objects into Range protos. Each `region` of
      `regions` is processed in turn, yielding one or more Range protos. This
      function inspects the contents of `region` to determine how to convert it to
      Range(s) protos. The following types of `region` strings are supported:
  
        * If region ends with an extension known in _get_parser_for_file, we treat
          region as a file and read the Range protos from it with the corresponding
          reader from _get_parser_for_file, yielding each Range from the file in
          order.
        * Otherwise we parse region as a region literal (`chr20:1-10`) and return
          the Range proto.
  
      Args:
        regions: iterable[str]. Converts each element of this iterable into
          region(s).
        contig_map: An optional dictionary mapping from contig names to ContigInfo
          protobufs. If provided, allows literals of the format "contig_name",
          which will be parsed into a Range with reference_name=contig_name,
          start=0, end=n_bases where n_bases comes from the ContigInfo.
  
      Yields:
        A Range proto.
      """
      for region in regions:
          reader = _get_parser_for_file(region)
          if reader:
              for elt in reader(region):
                  yield elt
          else:
              yield parse_literal(region, contig_map)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import re
  from typing import Dict, Iterable, Optional, Sequence
  from absl import logging
  from etils import epath
  import intervaltree
  import six
  from third_party.nucleus.io import bed
  from third_party.nucleus.protos import position_pb2
  from third_party.nucleus.protos import range_pb2
  from third_party.nucleus.protos import reference_pb2
  from third_party.nucleus.protos import variants_pb2
label_desc: Use image node_id 7 for calling a global function with example usage: from_regions(regions, contig_map) without return types