code: def _get_memory_on_localhost() -> int:
      """Fail-safe method to get total memory. Also respects docker/cgroup limitations."""
      import psutil
  
      memory = psutil.virtual_memory().total
      try:
          if os.path.isfile(
              "/sys/fs/cgroup/memory/memory.limit_in_bytes"
          ):
              with open(
                  "/sys/fs/cgroup/memory/memory.limit_in_bytes", "r"
              ) as file:
                  mem_limit = file.read().replace("\n", "").strip()
                  if mem_limit and 0 < int(mem_limit) < int(memory):
                      # if mem limit from cgroup bigger than total memory -> use total memory
                      memory = int(mem_limit)
      except:  # noqa: E722
          # Do nothing
          pass
  
      return memory
  
imports: import os
  import platform
  import socket
  import subprocess
  import sys
  from typing import Dict, List, Union
  import lazycluster.settings
  from .utils import Environment
label_desc: Use image node_id 11 for calling a global function with example usage: _get_memory_on_localhost() and returns: memory