code: def is_valid_ip(ip):
      """Returns true if the given string is a well-formed IP address.
  
      Supports IPv4 and IPv6.
      """
      if not ip or "\x00" in ip:
          # getaddrinfo resolves empty strings to localhost, and truncates
          # on zero bytes.
          return False
      try:
          res = socket.getaddrinfo(
              ip,
              0,
              socket.AF_UNSPEC,
              socket.SOCK_STREAM,
              0,
              socket.AI_NUMERICHOST,
          )
          return bool(res)
      except socket.gaierror as e:
          if e.args[0] == socket.EAI_NONAME:
              return False
          raise
      return True
  
imports: from __future__ import absolute_import, division, print_function
  import errno
  import os
  import sys
  import socket
  import stat
  from tornado.concurrent import dummy_executor, run_on_executor
  from tornado.ioloop import IOLoop
  from tornado.platform.auto import set_close_exec
  from tornado.util import PY3, Configurable, errno_from_exception
label_desc: Use image node_id 3 for calling a global function with example usage: is_valid_ip(ip) and returns: True, False, bool, False