code: public static String defaultDeviceForThread() {
          Integer deviceForThread = Nd4j.getAffinityManager().getDeviceForThread(Thread.currentThread());
          String deviceName = null;
          //gpu
          if(Nd4j.getBackend().getClass().getName().contains("JCublasBackend")) {
              deviceName = "/device:gpu:" + deviceForThread;
          }
          else {
              deviceName = "/device:cpu:" + deviceForThread;
          }
  
  
          return deviceName;
      }
docs: Infers the device for the given thread
  based on the {@link Nd4j#getAffinityManager()}
  Usually, this will either be a gpu or cpu
  reserved for the current device.
  You can think of the "current thread"
  as a worker. This is mainly useful with multiple gpus
  @return