code: def validate_machine_configuration(
      cpu_cores, memory, accelerator_type, accelerator_count
  ):
      """Validates machine confgurations for a GCP job.
  
      Args:
          cpu_cores: Number of virtual CPU cores.
          memory: Amount of memory in GB.
          accelerator_type: Instance of 'MachineConfig.AcceleratorType'.
          accelerator_count: Number of accelerators. Defaults to 1.
  
      Raises:
          ValueError, if machine configuration is not a valid GCP configuration.
      """
      valid_configurations = _get_valid_machine_configurations()
  
      # For TPU workers created using AI platform CPU/memory specification is not
      # required.
      if (
          accelerator_type.value == "TPU_V2"
          or accelerator_type.value == "TPU_V3"
      ):
          cpu_cores = None
          memory = None
  
      current_config = (
          cpu_cores,
          memory,
          accelerator_type.value,
          accelerator_count,
      )
      if current_config not in valid_configurations:
          raise ValueError(
              "Invalid machine configuration: cpu_cores:{}, memory:{}, "
              "accelerator_type:{}, accelerator_count:{}. Please see the "
              "following AI platform comptibility table for all valid "
              "configurations: "
              "https://cloud.google.com/ml-engine/docs/using-gpus#"
              "compute-engine-machine-types-with-gpu. If you are using TPU "
              "accelerator, please specify accelerator count as 8.".format(
                  cpu_cores,
                  memory,
                  str(accelerator_type),
                  accelerator_count,
              )
          )
  
file_path: cloud/src/python/tensorflow_cloud/core/gcp.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import re
  import google.auth
label_desc: Use image node_id 2 for calling a global function with example usage: validate_machine_configuration(cpu_cores, memory, accelerator_type, accelerator_count) without return types