code: def _calculate_average_field_lengths(self):
          
          accumulator = defaultdict(int)
          documents_with_field = defaultdict(int)
  
          for field_ref, length in self.field_lengths.items():
              _field_ref = FieldRef.from_string(field_ref)
              field = _field_ref.field_name
  
              documents_with_field[field] += 1
              accumulator[field] += length
  
          for field_name in self._fields:
              accumulator[field_name] /= documents_with_field[field_name]
  
          self.average_field_length = accumulator
docs: Calculates the average document length for this index