code: public boolean variableHasGradient(String varName){
          Preconditions.checkState(variables.containsKey(varName), "No variable with name \"%s\" exists", varName);
          SDVariable v = getVariable(varName);
          if(!v.dataType().isFPType() || v.isConstant())
              return false;
  
          return getGradForVariable(varName) != null;
      }
docs: Determine if the specified variable has a gradient with respect to the current loss. Note that:
  (a) Non-floating-point variables (integer, string, etc) will never have gradients<br>
  (b) This method will return false if no gradient function has been created yet. See {@link SameDiff#createGradFunction()}
  and {@link SameDiff#setLossVariables(String...)}<br>
  (c) Floating point variables may not have any gradient if the specified loss variables does not depend on the
  specified variable at all. In this case, "no gradient" for floating point is equivalent to "always 0"<br>
  
  @param varName Name of the variable to check the existence of a gradient variable for
  @return True if a gradient variable exists for the specified variable, for the current loss