code: def create_profiler_api_call(logdir):
      api = ProfilerApi(logdir)
      routes = {
          "runs": (api.runs, []),
          "views": (api.views, ["run"]),
          "workers": (api.workers, ["run", "view"]),
          "spans": (api.spans, ["run", "worker"]),
          "timeunits": (api.timeunits, []),
          "descriptions": (api.descriptions, ["lang"]),
          "overview/environment": (
              api.overview_environment,
              ["run", "worker", "span"],
          ),
          "overview/model_perspective": (
              api.model_perspective,
              ["run", "worker", "span", "time_unit"],
          ),
          "overview/model_perspective_perstep": (
              api.model_perspective_perstep,
              ["run", "worker", "span", "device_type", "time_unit"],
          ),
          "overview/event_type_perspective": (
              api.event_type_perspective,
              ["run", "worker", "span", "device_type", "time_unit"],
          ),
          "overview/event_type_model_perspective": (
              api.event_type_model_perspective,
              ["run", "worker", "span", "time_unit"],
          ),
          "overview/userdefined_perspective": (
              api.userdefined_perspective,
              ["run", "worker", "span", "time_unit"],
          ),
          "operator/pie": (
              api.operator_pie,
              ["run", "worker", "span", "topk", "time_unit"],
          ),
          "operator/pie_expand": (
              api.operator_pie_expand,
              [
                  "run",
                  "worker",
                  "span",
                  "topk",
                  "device_type",
                  "time_unit",
              ],
          ),
          "operator/table": (
              api.operator_table,
              [
                  "run",
                  "worker",
                  "span",
                  "group_by",
                  "search_name",
                  "time_unit",
              ],
          ),
          "operator/stack_table": (
              api.operator_stack_table,
              [
                  "run",
                  "worker",
                  "span",
                  "op_name",
                  "group_by",
                  "time_unit" "input_shape",
              ],
          ),
          "kernel/pie": (
              api.kernel_pie,
              ["run", "worker", "span", "topk", "time_unit"],
          ),
          "kernel/tensorcore_pie": (
              api.kernel_tc_pie,
              ["run", "worker", "span", "topk", "time_unit"],
          ),
          "kernel/table": (
              api.kernel_table,
              [
                  "run",
                  "worker",
                  "span",
                  "group_by",
                  "search_name",
                  "time_unit",
              ],
          ),
          "distributed/info": (
              api.distributed_info,
              ["run", "worker", "span"],
          ),
          "distributed/steps": (
              api.distributed_steps,
              ["run", "worker", "span"],
          ),
          "distributed/histogram": (
              api.distributed_histogram,
              ["run", "worker", "span", "step", "time_unit"],
          ),
          "trace": (api.trace, ["run", "worker", "span"]),
          "memory/devices": (
              api.memory_devices,
              ["run", "worker", "span"],
          ),
          "memory/curve": (
              api.memory_curve,
              ["run", "worker", "span", "device_type", "time_unit"],
          ),
          "memory/memory_events": (
              api.memory_events,
              [
                  "run",
                  "worker",
                  "span",
                  "device_type",
                  "min_size",
                  "max_size",
                  "search_name",
                  "time_unit",
              ],
          ),
          "memory/op_memory_events": (
              api.op_memory_events,
              ["run", "worker", "span", "device_type", "search_name"],
          ),
          "comparison/phase": (
              api.comparison_phase,
              [
                  "base_run",
                  "base_worker",
                  "base_span",
                  "exp_run",
                  "exp_worker",
                  "exp_span",
              ],
          ),
          "comparison/phase_diff": (
              api.comparison_phase_diff,
              [
                  "base_run",
                  "base_worker",
                  "base_span",
                  "exp_run",
                  "exp_worker",
                  "exp_span",
              ],
          ),
          "comparison/phase_table": (
              api.comparison_phase_table,
              [
                  "base_run",
                  "base_worker",
                  "base_span",
                  "exp_run",
                  "exp_worker",
                  "exp_span",
              ],
          ),
          "comparison/phase_inner": (
              api.comparison_phase_inner,
              [
                  "base_run",
                  "base_worker",
                  "base_span",
                  "exp_run",
                  "exp_worker",
                  "exp_span",
                  "phase_name",
              ],
          ),
          "comparison/phase_diff_inner": (
              api.comparison_phase_diff_inner,
              [
                  "base_run",
                  "base_worker",
                  "base_span",
                  "exp_run",
                  "exp_worker",
                  "exp_span",
                  "phase_name",
              ],
          ),
          "comparison/phase_table_inner": (
              api.comparison_phase_table_inner,
              [
                  "base_run",
                  "base_worker",
                  "base_span",
                  "exp_run",
                  "exp_worker",
                  "exp_span",
                  "phase_name",
              ],
          ),
          "component_tabs": (api.component_tabs, []),
      }
  
      def call(path: str, args):
          route = routes.get(path)
          if not route:
              return (
                  json.dumps(gen_result(status=1, msg="api not found")),
                  "application/json",
                  None,
              )
          method, call_arg_names = route
          call_args = [args.get(name) for name in call_arg_names]
          return method(*call_args)
  
      return call
  
imports: import json
  from .profiler_reader import ProfilerReader
  from visualdl.server.api import gen_result
  from visualdl.server.api import result
label_desc: Use image node_id 1 for calling a global function with example usage: create_profiler_api_call(logdir) and returns: call, method, json,  str,  None