code: def _reconstruct_metadata_for_attempt(all_metadata, attempt_id):
      have_all_attempt_id = True
      attempts_start = {}
      post_filter = []
      for v in all_metadata:
          if v["field_name"] == "attempt":
              attempts_start[int(v["value"])] = v["ts_epoch"]
          all_tags = v.get("tags")
          if all_tags is None:
              all_tags = []
          for t in all_tags:
              match_result = attempt_id_re.match(t)
              if match_result:
                  if int(match_result.group(1)) == attempt_id:
                      post_filter.append(v)
                  break
          else:
              # We didn't encounter a match for attempt_id
              have_all_attempt_id = False
  
      if not have_all_attempt_id:
          # We reconstruct base on the attempts_start
          start_ts = attempts_start.get(attempt_id, -1)
          if start_ts < 0:
              return []  # No metadata since the attempt hasn't started
          # Doubt we will be using Python in year 3000
          end_ts = attempts_start.get(attempt_id + 1, 32503680000000)
          post_filter = [
              v
              for v in all_metadata
              if v["ts_epoch"] >= start_ts and v["ts_epoch"] < end_ts
          ]
  
      return post_filter
  
imports: import json
  import os
  import re
  import time
  from collections import namedtuple
  from itertools import chain
  from metaflow.exception import MetaflowInternalError, MetaflowTaggingError
  from metaflow.tagging_util import validate_tag
  from metaflow.util import get_username, resolve_identity_as_tuple, is_stringish
label_desc: Use image node_id 33 for calling the MetadataProvider obj's underlying member method code with example usage: obj._reconstruct_metadata_for_attempt(all_metadata, attempt_id) and returns: post_filter, list