Importing inside functions - it is a very rare case and most often a crutch. This is only useful for runners with optional importing, for example.
In other cases, the use of import in the middle of the code - it's bad, because I do not see the whole list of modules used