code: def as_container_host(
      self, container_host: Optional[str] = None
  ) -> Self:
      if self.host_or_ip not in [
          "localhost",
          "host.docker.internal",
          "host.k3d.internal",
      ]:
          return self
  
      if container_host is None:
          # TODO: we could move config.py to syft and then the Settings singleton
          # could be importable in all parts of the code
          container_host = os.getenv("CONTAINER_HOST", None)
  
      if container_host:
          if container_host == "docker":
              hostname = "host.docker.internal"
          elif container_host == "podman":
              hostname = "host.containers.internal"
          else:
              hostname = "host.k3d.internal"
      else:
          # convert it back for non container clients
          hostname = "localhost"
  
      return self.__class__(
          protocol=self.protocol,
          host_or_ip=hostname,
          port=self.port,
          path=self.path,
      )
  
imports: from __future__ import annotations
  import copy
  import os
  import re
  from typing import Optional
  from typing import Union
  from urllib.parse import urlparse
  import requests
  from typing_extensions import Self
  from ..serde.serializable import serializable
  from ..util.util import verify_tls
label_desc: Use image node_id 4 for calling the GridURL obj's underlying member method code with example usage: obj.as_container_host(container_host) and returns: self, self