Let's say you have the source code of this repo cloned to /somepath/stylegan2-ada-pytorch
which means that the directories you quoted are at /somepath/stylegan2-ada-pytorch/torch_utils
and /somepath/stylegan2-ada-pytorch/dnnlib
, respectively.
Now let's say you have a python script that you want to access this code. It can be anywhere on your machine, as long as you add this to the top of your python script:
import os
import sys
#save the literal filepath to both directories as strings
tu_path = os.path.join('somepath','stylegan2-ada-pytorch','torch_utils')
dnnlib_path = os.path.join('somepath','stylegan2-ada-pytorch','dnnlib')
#add those strings to python path
sys.path.append(tu_path)
sys.path.append(dnnlib_path )
Note that this only adds those location to PYTHONPATH for the duration of that python script running, so you need this at the top of any python script that intends to use those libraries.