code: def materialize(reference_dict, source):
      
      materialized_dict = {}
      for field in reference_dict:
          reference = reference_dict[field]
          if isinstance(reference, list):
              materialized_dict[field] = [source[index] for index in reference]
          elif reference is not None:
              materialized_dict[field] = source[reference]
          else:
              materialized_dict[field] = None
      return materialized_dict
docs: Replace indices by actual elements in a reference mapping
      :param reference_dict: mapping str -> int | int[]
      :param source: list of elements
      :return: mapping str -> element | element[]