code: def trf(
      fun,
      jac,
      x0,
      f0,
      J0,
      lb,
      ub,
      ftol,
      xtol,
      gtol,
      max_nfev,
      x_scale,
      loss_function,
      tr_solver,
      tr_options,
      verbose,
  ):
      # For efficiency, it makes sense to run the simplified version of the
      # algorithm when no bounds are imposed. We decided to write the two
      # separate functions. It violates the DRY principle, but the individual
      # functions are kept the most readable.
      if np.all(lb == -np.inf) and np.all(ub == np.inf):
          return trf_no_bounds(
              fun,
              jac,
              x0,
              f0,
              J0,
              ftol,
              xtol,
              gtol,
              max_nfev,
              x_scale,
              loss_function,
              tr_solver,
              tr_options,
              verbose,
          )
      else:
          return trf_bounds(
              fun,
              jac,
              x0,
              f0,
              J0,
              lb,
              ub,
              ftol,
              xtol,
              gtol,
              max_nfev,
              x_scale,
              loss_function,
              tr_solver,
              tr_options,
              verbose,
          )
  
file_path: scipy/scipy/optimize/_lsq/trf.py
imports: import numpy
  from numpy.linalg import norm
  from scipy.linalg import svd, qr
  from scipy.sparse.linalg import lsmr
  from scipy.optimize import OptimizeResult
  from .common import step_size_to_bound, find_active_constraints, in_bounds, make_strictly_feasible, intersect_trust_region, solve_lsq_trust_region, solve_trust_region_2d, minimize_quadratic_1d, build_quadratic_1d, evaluate_quadratic, right_multiplied_operator, regularized_lsq_operator, CL_scaling_vector, compute_grad, compute_jac_scale, check_termination, update_tr_radius, scale_for_robust_loss_function, print_header_nonlinear, print_iteration_nonlinear
label_desc: Use image node_id 1 for calling a global function with example usage: trf(fun, jac, x0, f0, J0, lb, ub, ftol, xtol, gtol, max_nfev, x_scale, loss_function, tr_solver, tr_options, verbose) and returns: trf_no_bounds, trf_bounds