code: public <X extends SDVariable> X setupFunction(X function) {
          Preconditions.checkNotNull(function, "Passed in function must not be null!");
          if (function instanceof SDVariable) {
              if (function.getSameDiff() != this) {
                  function.setSameDiff(this);
              }
              return function;
          }
          return function;
      }
docs: Attempts to insert the {@link DifferentialFunction} reference in to this {@link SameDiff} instance.
  If the given array field with the given index already exists, it will do a reference check to ensure that the 2
  array fields are the same. If not, an exception is thrown.<br>
  If the instances are the same (by semantics, not reference) then it will just return the original instance.
  This is to ensure that instances that are created are unique and reference checked.
  
  @param function the array field to attempt to create
  @return Original instance