code: def lin_constraint_jac(
      x: np.ndarray, flat_idxr: List[int], coeffs: np.ndarray, n: int
  ) -> np.ndarray:
      r"""Return the Jacobian associated with a linear constraint.
  
      Args:
          x: The input array.
          flat_idxr: The indices for the elements of x that appear in the constraint.
          coeffs: The coefficients corresponding to the indices.
          n: number of elements
  
      Returns:
          The Jacobian.
      """
      # TODO: Use sparse representation (not sure if scipy optim supports that)
      jac = np.zeros(n)
      jac[flat_idxr] = coeffs
      return jac
  
imports: from __future__ import annotations
  from functools import partial
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from botorch.exceptions.errors import CandidateGenerationError, UnsupportedError
  from scipy.optimize import Bounds
  from torch import Tensor
label_desc: Use image node_id 4 for calling a global function with example usage: lin_constraint_jac(x, flat_idxr, coeffs, n) and returns: jac