code: def _build_requested_prefetches(
          self,
          prefetches,
          requirements,
          model,
          fields,
          filters
      ):
          
  
          for name, field in six.iteritems(fields):
              original_field = field
              if isinstance(field, DynamicRelationField):
                  field = field.serializer
              if isinstance(field, serializers.ListSerializer):
                  field = field.child
              if not isinstance(field, serializers.ModelSerializer):
                  continue
  
              source = field.source or name
              if '.' in source:
                  raise ValidationError(
                      'nested relationship values '
                      'are not supported'
                  )
  
              if source in prefetches:
                  # ignore duplicated sources
                  continue
  
              is_remote = is_field_remote(model, source)
              is_id_only = getattr(field, 'id_only', lambda: False)()
              if is_id_only and not is_remote:
                  continue
  
              related_queryset = getattr(original_field, 'queryset', None)
  
              if callable(related_queryset):
                  related_queryset = related_queryset(field)
  
              source = field.source or name
              # Popping the source here (during explicit prefetch construction)
              # guarantees that implicitly required prefetches that follow will
              # not conflict.
              required = requirements.pop(source, None)
  
              prefetch_queryset = self._build_queryset(
                  serializer=field,
                  filters=filters.get(name, {}),
                  queryset=related_queryset,
                  requirements=required
              )
  
              # Note: There can only be one prefetch per source, even
              #       though there can be multiple fields pointing to
              #       the same source. This could break in some cases,
              #       but is mostly an issue on writes when we use all
              #       fields by default.
              prefetches[source] = self._create_prefetch(
                  source,
                  prefetch_queryset
              )
  
          return prefetches
docs: Build a prefetch dictionary based on request requirements.