code: def _get_instance_config(
      self, resources_needed, queue_name, timeout=300
  ):
      # image_response = self.compute.images().getFromFamily(
      #    project='studio-ed756', family='studioml').execute()
  
      image_response = None
  
      if image_response is None:
          image_response = (
              self.compute.images()
              .getFromFamily(
                  project="ubuntu-os-cloud", family="ubuntu-1604-lts"
              )
              .execute()
          )
  
      source_disk_image = image_response["selfLink"]
  
      # Configure the machine
      machine_type = self._generate_machine_type(resources_needed)
      self.logger.debug("Machine type = {}".format(machine_type))
  
      with open(self.startup_script_file, "r") as f:
          startup_script = f.read()
  
      with open(self.install_studio_script) as f:
          install_studio_script = f.read()
  
      startup_script = insert_user_startup_script(
          self.user_startup_script, startup_script, self.logger
      )
  
      startup_script = startup_script.replace(
          "{install_studio}", install_studio_script
      )
      startup_script = startup_script.format(
          studioml_branch=self.branch,
          repo_url=self.repo_url,
          log_bucket=self.log_bucket,
          use_gpus=resources_needed.get("gpus", 0),
      )
  
      self.logger.info("Startup script:")
      self.logger.info(startup_script)
  
      with open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"], "r") as f:
          credentials = f.read()
  
      if self.auth_cookie is not None:
          auth_key = os.path.basename(self.auth_cookie)
          with open(self.auth_cookie, "r") as f:
              auth_data = f.read()
      else:
          auth_key = None
          auth_data = None
  
      config = {
          "machineType": machine_type,
          # Specify the boot disk and the image to use as a source.
          "disks": [
              {
                  "boot": True,
                  "autoDelete": True,
                  "initializeParams": {
                      "sourceImage": source_disk_image,
                  },
              }
          ],
          # Specify a network interface with NAT to access the public
          # internet.
          "networkInterfaces": [
              {
                  "network": "global/networks/default",
                  "accessConfigs": [
                      {"type": "ONE_TO_ONE_NAT", "name": "External NAT"}
                  ],
              }
          ],
          # Allow the instance to access cloud storage and logs.
          "serviceAccounts": [
              {
                  "email": "default",
                  "scopes": [
                      "https://www.googleapis.com/auth/cloud-platform",
                  ],
              }
          ],
          # Metadata is readable from the instance and allows you to
          # pass configuration from deployment scripts to instances.
          "metadata": {
              "items": [
                  {"key": "startup-script", "value": startup_script},
                  {"key": "credentials", "value": credentials},
                  {"key": "queue_name", "value": queue_name},
                  {"key": "auth_key", "value": auth_key},
                  {"key": "auth_data", "value": auth_data},
                  {"key": "timeout", "value": str(timeout)},
              ]
          },
          "scheduling": {"preemptilble": False},
      }
  
      if "hdd" in resources_needed.keys():
          config["disks"][0]["initializeParams"][
              "diskSizeGb"
          ] = memstr2int(resources_needed["hdd"]) / memstr2int("1Gb")
  
      if resources_needed["gpus"] > 0:
          gpu_type = "nvidia-tesla-k80"
          config["guestAccelerators"] = [
              {
                  "acceleratorType": "projects/{}/zones/{}/acceleratorTypes/{}".format(
                      self.projectid, self.zone, gpu_type
                  ),
                  "acceleratorCount": resources_needed["gpus"],
              }
          ]
  
          config["scheduling"]["onHostMaintenance"] = "TERMINATE"
          config["automaticRestart"] = True
  
      return config
  
imports: import os
  import time
  import googleapiclient.discovery
  import uuid
  import math
  import json
  from studio import git_util
  from studio.util import logs
  from studio.util.gpu_util import memstr2int
  from .cloud_worker_util import insert_user_startup_script
label_desc: Use image node_id 4 for calling the GCloudWorkerManager obj's underlying member method code with example usage: obj._get_instance_config(resources_needed, queue_name, timeout) and returns: config