  from plugins.PluginLoader import PluginLoader
  
  class TrainingProcessor(object):
      arguments = None
  
      def __init__(self, subparser, command, description='default'):
          self.parse_arguments(description, subparser, command)
 
</s> remove         self.lock = Lock()
 </s> add         self.lock = threading.Lock() </s> remove from threading import Lock
 </s> add import threading  </s> remove         import threading
 </s> add  </s> remove         import tensorflow as tf
        from keras.backend.tensorflow_backend import set_session
 </s> add         import_tensorflow_keras()
tf = None
set_session = None
def import_tensorflow_keras():
    ''' Import the TensorFlow and keras set_session modules only when they are required '''
    global tf
    global set_session
    if tf is None or set_session is None:
        import tensorflow
        import keras.backend.tensorflow_backend
        tf = tensorflow
        set_session = keras.backend.tensorflow_backend.set_session

  from plugins.PluginLoader import PluginLoader
  
tf = None
set_session = None
def import_tensorflow_keras():
    ''' Import the TensorFlow and keras set_session modules only when they are required '''
    global tf
    global set_session
    if tf is None or set_session is None:
        import tensorflow
        import keras.backend.tensorflow_backend
        tf = tensorflow
        set_session = keras.backend.tensorflow_backend.set_session

  class TrainingProcessor(object):
      arguments = None
  
      def __init__(self, subparser, command, description='default'):
          self.parse_arguments(description, subparser, command)
keep add keep keep keep keep keep
 Only import DLIB related modules when required and minor import relocations (#315)

* Move imports to top and add conditions to load modules requiring GPU

* Fix type

* Fix typo

* Import relocation and dlib import on demand

* refactor to remove extra code lines

* remove unnecessary sys import 
scripts/train.py