parameters: (devices)
return_statement: return DeviceDetails(device_map, num_cores)
docstring: Returns a dict of hosts to cores and total cores given devices names.
  
      Returns a namedtuple with two attributes:
        device_map: A map of host_ids to a list of core_ids.
        total_cores: The total number of cores within the TPU system.
  
      Args:
        devices: A list of devices returned by session.list_devices()
docstring_summary: Returns a dict of hosts to cores and total cores given devices names.
docstring_tokens: Returns a dict of hosts to cores and total cores given devices names .
function: def _get_device_dict_and_cores(devices):
      """Returns a dict of hosts to cores and total cores given devices names.
  
      Returns a namedtuple with two attributes:
        device_map: A map of host_ids to a list of core_ids.
        total_cores: The total number of cores within the TPU system.
  
      Args:
        devices: A list of devices returned by session.list_devices()
      """
      device_map = collections.defaultdict(list)
      num_cores = 0
      for device in devices:
        match = _TPU_DEVICE_REGEX.match(device.name)
        if match:
          host_id = match.group('host_id')
          core_id = match.group('core_id')
          device_map[host_id].append(core_id)
          num_cores += 1
      return DeviceDetails(device_map, num_cores)
function_tokens: def _get_device_dict_and_cores ( devices ) : device_map = collections . defaultdict ( list ) num_cores = 0 for device in devices : match = _TPU_DEVICE_REGEX . match ( device . name ) if match : host_id = match . group ( 'host_id' ) core_id = match . group ( 'core_id' ) device_map [ host_id ] . append ( core_id ) num_cores += 1 return DeviceDetails ( device_map , num_cores )