code: def py_scanstring(
      s, end, strict=True, _b=BACKSLASH, _m=STRINGCHUNK.match
  ):
      """Scan the string s for a JSON string. End is the index of the
      character in s after the quote that started the JSON string.
      Unescapes all valid JSON string escape sequences and raises ValueError
      on attempt to decode an invalid string. If strict is False then literal
      control characters are allowed in the string.
  
      Returns a tuple of the decoded string and the index of the character in s
      after the end quote."""
      chunks = []
      _append = chunks.append
      begin = end - 1
      while 1:
          chunk = _m(s, end)
          if chunk is None:
              raise JSONDecodeError(
                  "Unterminated string starting at", s, begin
              )
          end = chunk.end()
          content, terminator = chunk.groups()
          # Content is contains zero or more unescaped string characters
          if content:
              _append(content)
          # Terminator is the end of string, a literal control character,
          # or a backslash denoting that an escape sequence follows
          if terminator == '"':
              break
          elif terminator != "\\":
              if strict:
                  # msg = "Invalid control character %r at" % (terminator,)
                  msg = "Invalid control character {0!r} at".format(
                      terminator
                  )
                  raise JSONDecodeError(msg, s, end)
              else:
                  _append(terminator)
                  continue
          try:
              esc = s[end]
          except IndexError:
              raise JSONDecodeError(
                  "Unterminated string starting at", s, begin
              ) from None
          # If not a unicode escape sequence, must be in the lookup table
          if esc != "u":
              try:
                  char = _b[esc]
              except KeyError:
                  msg = "Invalid \\escape: {0!r}".format(esc)
                  raise JSONDecodeError(msg, s, end)
              end += 1
          else:
              uni = _decode_uXXXX(s, end)
              end += 5
              if 0xD800 <= uni <= 0xDBFF and s[end : end + 2] == "\\u":
                  uni2 = _decode_uXXXX(s, end + 1)
                  if 0xDC00 <= uni2 <= 0xDFFF:
                      uni = 0x10000 + (
                          ((uni - 0xD800) << 10) | (uni2 - 0xDC00)
                      )
                      end += 6
              char = chr(uni)
          _append(char)
      return "".join(chunks), end
  
file_path: catboost/contrib/tools/python3/src/Lib/json/decoder.py
imports: import re
  from json import scanner
label_desc: Use image node_id 2 for calling a global function with example usage: py_scanstring(s, end, strict, _b, _m) and returns: str,  end