code: def _start_heartbeat(
      self,
      heartbeat_type,
      flow_id,
      run_id,
      step_name=None,
      task_id=None,
  ):
      if self._already_started():
          # A single ServiceMetadataProvider instance can not start
          # multiple heartbeat side cars of any type/combination. Either a
          # single run heartbeat or a single task heartbeat can be started
          raise Exception("heartbeat already started")
      # create init message
      payload = {}
      if heartbeat_type == HeartbeatTypes.TASK:
          # create task heartbeat
          data = {
              "flow_id": flow_id,
              "run_number": run_id,
              "step_name": step_name,
              "task_id": task_id,
          }
          payload[HB_URL_KEY] = self.url_task_template.format(**data)
      elif heartbeat_type == HeartbeatTypes.RUN:
          # create run heartbeat
          data = {"flow_id": flow_id, "run_number": run_id}
  
          payload[HB_URL_KEY] = self.url_run_template.format(**data)
      else:
          raise Exception("invalid heartbeat type")
      service_version = self.version()
      payload["service_version"] = service_version
      # start sidecar
      if service_version is None or version_parse(
          service_version
      ) < version_parse("2.0.4"):
          # if old version of the service is running
          # then avoid running real heartbeat sidecar process
          self.sidecar = Sidecar("none")
      else:
          self.sidecar = Sidecar("heartbeat")
      self.sidecar.start()
      self.sidecar.send(Message(MessageTypes.BEST_EFFORT, payload))
  
imports: import os
  import random
  import requests
  import time
  from metaflow.exception import MetaflowException, MetaflowTaggingError, MetaflowInternalError
  from metaflow.metaflow_config import SERVICE_RETRY_COUNT, SERVICE_HEADERS, SERVICE_URL
  from metaflow.metadata import MetadataProvider
  from metaflow.metadata.heartbeat import HB_URL_KEY
  from metaflow.sidecar import Message, MessageTypes, Sidecar
  from metaflow.util import version_parse
label_desc: Use image node_id 9 for calling the ServiceMetadataProvider obj's underlying member method code with example usage: obj._start_heartbeat(heartbeat_type, flow_id, run_id, step_name, task_id) without return types