code: def parse_literal(region_literal, contig_map=None):
      """Parses a Range from a string representation like chr:start-end.
  
      The region literal must conform to the following pattern:
  
        chromosome:start-end
        chromosome:position
        chromosome  [if contig_map is provided]
  
      chromosome can be any non-empty string without whitespace. start and end must
      both be positive integers. They can contain commas for readability. start and
      end are positions not offsets, so start == 1 means an offset of zero. If only
      a single position is provided, this creates a 1 bp interval starting at
      position - 1 and ending at position.
  
      Inspired by the samtools region specification:
      http://www.htslib.org/doc/samtools.html
  
      Args:
        region_literal: str. The literal to parse.
        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.
  
      Returns:
        nucleus.genomics.v1.Range.
  
      Raises:
        ValueError: if region_literal cannot be parsed.
      """
  
      def parse_position(pos_str):
          return int(pos_str.replace(",", ""))
  
      matched = _REGION_LITERAL_REGEXP.match(region_literal)
      if matched:
          chrom, start, end = matched.groups()
          return make_range(
              chrom, parse_position(start) - 1, parse_position(end)
          )
  
      matched = _POSITION_LITERAL_REGEXP.match(region_literal)
      if matched:
          chrom, pos = matched.groups()
          pos = parse_position(pos)
          return make_range(chrom, pos - 1, pos)
  
      if contig_map and region_literal in contig_map:
          # If the region_literals is an exact contig name like chr1 or MT return a
          # range over the entire contig.
          return make_range(
              region_literal, 0, contig_map[region_literal].n_bases
          )
      raise ValueError(
          'Could not parse "{}" as a region literal.  Region literals '
          'should have the form "chr:start-stop" or "chr:start" or '
          'just "chr".  A common error is to use the "chr" prefix on '
          "inputs that don't have it, or vice-versa.".format(
              region_literal
          )
      )
  
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 10 for calling a global function with example usage: parse_literal(region_literal, contig_map) and returns: int, make_range, make_range, make_range