code: def is_disconnect(self, e, connection, cursor):
      if isinstance(e, self.dbapi.Error):
          # check the "closed" flag.  this might not be
          # present on old psycopg2 versions.   Also,
          # this flag doesn't actually help in a lot of disconnect
          # situations, so don't rely on it.
          if getattr(connection, "closed", False):
              return True
  
          # checks based on strings.  in the case that .closed
          # didn't cut it, fall back onto these.
          str_e = str(e).partition("\n")[0]
          for msg in [
              # these error messages from libpq: interfaces/libpq/fe-misc.c
              # and interfaces/libpq/fe-secure.c.
              "terminating connection",
              "closed the connection",
              "connection not open",
              "could not receive data from server",
              "could not send data to server",
              # psycopg2 client errors, psycopg2/connection.h,
              # psycopg2/cursor.h
              "connection already closed",
              "cursor already closed",
              # not sure where this path is originally from, it may
              # be obsolete.   It really says "losed", not "closed".
              "losed the connection unexpectedly",
              # these can occur in newer SSL
              "connection has been closed unexpectedly",
              "SSL error: decryption failed or bad record mac",
              "SSL SYSCALL error: Bad file descriptor",
              "SSL SYSCALL error: EOF detected",
              "SSL SYSCALL error: Operation timed out",
              "SSL SYSCALL error: Bad address",
          ]:
              idx = str_e.find(msg)
              if idx >= 0 and '"' not in str_e[:idx]:
                  return True
      return False
  
imports: from __future__ import annotations
  import collections.abc
  import logging
  import re
  from typing import cast
  from .None import ranges
  from ._psycopg_common import _PGDialect_common_psycopg
  from ._psycopg_common import _PGExecutionContext_common_psycopg
  from .base import PGIdentifierPreparer
  from .json import JSON
  from .json import JSONB
  from ...None import types
  from ...None import util
  from ...util import FastIntFlag
  from ...util import parse_user_argument_for_enum
label_desc: Use image node_id 20 for calling the PGDialect_psycopg2 obj's underlying member method code with example usage: obj.is_disconnect(e, connection, cursor) and returns: False, True, True