code: def cli_entrypoint(name: str):
      def cli_entrypoint_wrap(func):
          @wraps(func)
          def wrapper_func(*args, **kwargs):
              global tracer_provider
  
              init_tracing()
  
              assert (
                  tracer_provider is not None
              )  # make type checker happy
  
              token = context.attach(extract(os.environ))
              try:
                  tracer = trace_api.get_tracer_provider().get_tracer(
                      __name__
                  )
  
                  card_subcommand = _extract_token_after(
                      sys.argv, "card"
                  )
  
                  step_name = _extract_token_after(sys.argv, "step")
                  task_id = _extract_token_after(sys.argv, "--task-id")
                  run_id = _extract_token_after(sys.argv, "--run-id")
                  if step_name and task_id and run_id:
                      better_name = "/".join(
                          [run_id, step_name, task_id]
                      )
                  elif card_subcommand:
                      better_name = "card/" + card_subcommand
                  elif "run" in sys.argv:
                      better_name = "run"
                  else:
                      better_name = None
  
                  with tracer.start_as_current_span(
                      better_name or name,
                      kind=trace_api.SpanKind.SERVER,
                  ) as span:
                      span.set_attribute("cmd", " ".join(sys.argv))
                      span.set_attribute("pid", str(os.getpid()))
                      return func(*args, **kwargs)
              finally:
                  context.detach(token)
                  try:
                      tracer_provider.force_flush()
                  except Exception as e:  # pylint: disable=broad-except
                      print(
                          "TracerProvider failed to flush traces",
                          e,
                          file=sys.stderr,
                      )
  
          return wrapper_func
  
      return cli_entrypoint_wrap
  
imports: import os
  import sys
  from opentelemetry.sdk.trace import TracerProvider
  from opentelemetry.sdk.trace.export import BatchSpanProcessor
  from opentelemetry.propagate import set_global_textmap
  from opentelemetry.sdk.resources import SERVICE_NAME, Resource
  from opentelemetry.trace.span import format_trace_id
  from opentelemetry.propagate import extract, inject
  from functools import wraps
  import contextlib
  from typing import Dict, List, Optional
  from opentelemetry import trace, context
  from .span_exporter import get_span_exporter
label_desc: Use image node_id 4 for calling a global function with example usage: cli_entrypoint(name) and returns: cli_entrypoint_wrap, wrapper_func, func