code: public SDVariable var(String name, @NonNull INDArray arr) {
          if (variables.containsKey(name) && variables.get(name).getVariable().getArr() != null)
              throw new IllegalArgumentException("Another variable with the name " + name + " already exists.");
          Preconditions.checkState(arr.dataType().isFPType(), "Cannot create variable with non-floating point type:" +
                  " provided array has datatype %s. Variables must be floating point type to be trainable by backpropagation.\n" +
                  "For non floating point types, these should be created as placeholders or constants instead.", arr.dataType());
  
  
          if (name == null || name.length() < 1)
              name = getNewVarName();
  
          boolean duped = false;
          if(arr.isAttached()) {
              arr = arr.detach();
              duped = true;
          }
          if(arr.isView()) {
              arr = arr.dup();
              duped = true;
          }
  
          if(!duped) {
              for (DeviceLocalNDArray otherArr : variablesArrays.values()) {
                  if (otherArr.get() == arr) {    //Check for exact same object, to avoid array reuse (can result in unexpected behaviour)
                      arr = arr.dup();
                      break;
                  }
              }
          }
  
          SDVariable ret = new SDVariable(name, VariableType.VARIABLE, this, arr.shape(), arr.dataType(), new NDArraySupplierInitScheme(arr));
  
          associateArrayWithVariable(arr, ret);
          if (ArrayUtil.prod(arr.shape()) == 1) {
              try(MemoryWorkspace ws = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
                  ret.setScalarValue(Nd4j.scalar(arr.getDouble(0)));
              }
          }
  
          addVariable(ret);
          if (getShapeForVarName(name) == null)
              putShapeForVarName(name, arr.shape());
          return ret;
      }
docs: Create an {@link SDVariable} with the specified name, and associate the specified array with it<br>
  This is a VARIABLE type SDVariable - i.e., must be floating point, and is a trainable parameter. See {@link VariableType} for more details.
  @param arr Array to associate with the new variable
  @return New SDVariable with the specified name and array