docstr: Unescape a quoted string, by looking at \ that precede a quote.
  
  The input string should contain enclosing quotes, which are stripped away
  by this function.
  
  Due to the grammar definition of quoted strings, it is assumed that:
      * if there are \ preceding the closing quote, their number must be even
      * if there are \ preceding a quote in the middle of the string, their
        number must be odd
  
  Examples (with double quotes, but the same logic applies to single quotes):
      * "abc\"def"    -> abc"def
      * "abc\\\"def"  -> abc\"def
      * "abc\\"       -> abc\
      * "abc\\\\"     -> abc\\"
docstr_tok: ["Unescape","a","quoted","string",",","by","looking","at","\\","that","precede","a","quote",".","The","input","string","should","contain","enclosing","quotes",",","which","are","stripped","away","by","this","function",".","Due","to","the","grammar","definition","of","quoted","strings",",","it","is","assumed","that",":","*","if","there","are","\\","preceding","the","closing","quote",",","their","number","must","be","even","*","if","there","are","\\","preceding","a","quote","in","the","middle","of","the","string",",","their","number","must","be","odd","Examples","(","with","double","quotes",",","but","the","same","logic","applies","to","single","quotes",")",":","*","``","abc\\","''","def","''","-",">","abc","''","def","*","``","abc\\\\\\","''","def","''","-",">","abc\\","''","def","*","``","abc\\\\","''","-",">","abc\\","*","``","abc\\\\\\\\","''","-",">","abc\\\\","''"]
code: def _unescape_quoted_string(self, text: str) -> str:
      r"""
          Unescape a quoted string, by looking at \ that precede a quote.
  
          The input string should contain enclosing quotes, which are stripped away
          by this function.
  
          Due to the grammar definition of quoted strings, it is assumed that:
              * if there are \ preceding the closing quote, their number must be even
              * if there are \ preceding a quote in the middle of the string, their
                number must be odd
  
          Examples (with double quotes, but the same logic applies to single quotes):
              * "abc\"def"    -> abc"def
              * "abc\\\"def"  -> abc\"def
              * "abc\\"       -> abc\
              * "abc\\\\"     -> abc\\"
          """
      qc = text[0]  # quote character
      text = text[1:]  # remove first quote *but* keep the last one
      pattern = _ESC_QUOTED_STR[qc]
      match = pattern.search(text)
  
      if match is None:
          return text[0:-1]  # remove last quote
  
      tokens = []
      while match is not None:
          start, stop = match.span()
          # Add characters before the escaped sequence.
          tokens.append(text[0:start])
          # Un-escaping. Note that this works both for escaped quotes in the middle of
          # a string, as well as trailing backslashes where the end quote is stripped:
          #   \"    -> "  (escaped quote in the middle)
          #   \\"   -> \  (escaped trailing backslash)
          #   \\\"  -> \" (escaped backslash followed by escaped quote in the middle)
          #   \\\\" -> \\ (two escaped trailing backslashes)
          #   ...
          tokens.append(text[start + 1 : stop : 2])
          # Move on to next match.
          text = text[stop:]
          match = pattern.search(text)
  
      if len(text) > 1:
          # Add characters after the last match, removing the end quote.
          tokens.append(text[0:-1])
  
      return "".join(tokens)
  
imports: import sys
  import warnings
  from typing import Any, Dict, List, Optional, Tuple, Union
  from antlr4 import ParserRuleContext, TerminalNode, Token
  from antlr4.error.ErrorListener import ErrorListener
  from antlr4.tree.Tree import TerminalNodeImpl
  from hydra._internal.grammar.functions import FunctionCall, Functions
  from hydra._internal.grammar.utils import _ESC_QUOTED_STR
  from hydra.core.override_parser.types import ChoiceSweep, Glob, IntervalSweep, Key, Override, OverrideType, ParsedElementType, Quote, QuotedString, RangeSweep, ValueType
  from hydra.errors import HydraException
label_desc: Use image node_id 18 for calling the HydraOverrideVisitor obj's underlying member method code with example usage: obj._unescape_quoted_string(text) and returns: str, text