code: def batch_write_spans(
          self, name, spans, retry=method.DEFAULT, timeout=method.DEFAULT
      ):
          
          spans_pb_list = []
  
          for span_mapping in spans["spans"]:
              span_pb = _dict_mapping_to_pb(span_mapping, "Span")
              spans_pb_list.append(span_pb)
  
          self._gapic_api.batch_write_spans(
              name=name, spans=spans_pb_list, retry=retry, timeout=timeout
          )
docs: Sends new spans to Stackdriver Trace or updates existing traces. If the
          name of a trace that you send matches that of an existing trace, new
          spans are added to the existing trace. Attempt to update existing spans
          results undefined behavior. If the name does not match, a new trace is
          created with given set of spans.
  
          Args:
              name (str): Required. Name of the project where the spans belong.
                  The format is ``projects/PROJECT_ID``.
              spans (list[Union[dict, ~google.cloud.trace_v2.types.Span]]): A
                  collection of spans. If a dict is provided, it must be of the
                  same form as the protobuf message
                  :class:`~google.cloud.trace_v2.types.Span`
              retry (Optional[google.api_core.retry.Retry]):  A retry object used
                  to retry requests. If ``None`` is specified, requests will not
                  be retried.
              timeout (Optional[float]): The amount of time, in seconds, to wait
                  for the request to complete. Note that if ``retry`` is
                  specified, the timeout applies to each individual attempt.
  
          Raises:
              google.api_core.exceptions.GoogleAPICallError: If the request
                      failed for any reason.
              google.api_core.exceptions.RetryError: If the request failed due
                      to a retryable error and retry attempts failed.
              ValueError: If the parameters are invalid.