parameters: (filename, device_id_list, profiler_file_prefix)
docstring: Parse device id from filename.
docstring_summary: Parse device id from filename.
docstring_tokens: Parse device id from filename .
function: def parse_device_id(filename, device_id_list, profiler_file_prefix):
      """Parse device id from filename."""
      items = filename.split("_")
      if filename.startswith("step_trace_raw"):
          device_num = ""
          if len(items) > 3:
              device_num = items[3]
      else:
          device_num = items[-1].split(".")[0] if items[-1].split(".") else ""
  
      if device_num.isdigit() and '_'.join(items[:-1]) in profiler_file_prefix:
          device_id_list.add(device_num)
function_tokens: def parse_device_id ( filename , device_id_list , profiler_file_prefix ) : items = filename . split ( "_" ) if filename . startswith ( "step_trace_raw" ) : device_num = "" if len ( items ) > 3 : device_num = items [ 3 ] else : device_num = items [ - 1 ] . split ( "." ) [ 0 ] if items [ - 1 ] . split ( "." ) else "" if device_num . isdigit ( ) and '_' . join ( items [ : - 1 ] ) in profiler_file_prefix : device_id_list . add ( device_num )