I am not an expert here, but when you configure your DataBlock, you tell it how to get all the items with the get_items= argument. You tell it to use the get_image_files function which is part of fastai, it will take a given path and find all the files (recursively) under that path that are images. If you try it out:
fns = get_image_files(path)
fns
You will see that it is an L type object (a fancy list) that has a Path entry for each image file under that folder and the DataBlock will use that to create the DataLoaders when you you do:
dls = bears.dataloaders(path)
You also tell it to use:
get_y=parent_label
so use the parent (of the file) directory to get the label.