def get_machine_type(machine_type, accelerator_count):
  """Get machine type for the instance.

  - Use the user-specified machine_type if it is not None
  - Otherwise, use the standard type with cpu_count = 8 x accelerator_count
    if user-specified accelerator_count > 0
  - Otherwise, use the standard type with 8 cpu

  Args:
    machine_type: machine_type specified by the user
    accelerator_count: accelerator count

  Returns:
    the machine type used for the instance
  """
  if machine_type:
    return machine_type
  cpu_count = max(accelerator_count, 1) * 8
  return 'n1-standard-{}'.format(cpu_count)