docs: def _scobit_transform_deriv_v(systematic_utilities,
                                alt_IDs,
                                rows_to_alts,
                                shape_params,
                                output_array=None,
                                *args, **kwargs):
      """
      Parameters
      ----------
      systematic_utilities : 1D ndarray.
          All elements should be ints, floats, or longs. Should contain the
          systematic utilities of each observation per available alternative.
          Note that this vector is formed by the dot product of the design matrix
          with the vector of utility coefficients.
      alt_IDs : 1D ndarray.
          All elements should be ints. There should be one row per obervation per
          available alternative for the given observation. Elements denote the
          alternative corresponding to the given row of the design matrix.
      rows_to_alts : 2D scipy sparse matrix.
          There should be one row per observation per available alternative and
          one column per possible alternative. This matrix maps the rows of the
          design matrix to the possible alternatives for this dataset. All
          elements should be zeros or ones.
      shape_params : None or 1D ndarray.
          If an array, each element should be an int, float, or long. There
          should be one value per shape parameter of the model being used.
      output_array : 2D scipy sparse array.
          The array should be square and it should have
          `systematic_utilities.shape[0]` rows. It's data is to be replaced with
          the correct derivatives of the transformation vector with respect to
          the vector of systematic utilities. This argument is NOT optional.
  
      Returns
      -------
      output_array : 2D scipy sparse array.
          The shape of the returned array is `(systematic_utilities.shape[0],
          systematic_utilities.shape[0])`. The returned array specifies the
          derivative of the transformed utilities with respect to the systematic
          utilities. All elements are ints, floats, or longs.
      """
      # Note  the np.exp is  needed because the raw curvature params are the log
      # of the 'natural' curvature params. This is to ensure the natural shape
      # params are always positive
      curve_shapes = np.exp(shape_params)
      curve_shapes[np.isposinf(curve_shapes)] = max_comp_value
      long_curve_shapes = rows_to_alts.dot(curve_shapes)
  
      # Generate the needed terms for the derivative of the transformation with
      # respect to the systematic utility and guard against underflow or overflow
      exp_neg_v = np.exp(-1 * systematic_utilities)
  
      powered_term = np.power(1 + exp_neg_v, long_curve_shapes)
  
      small_powered_term = np.power(1 + exp_neg_v, long_curve_shapes - 1)
  
      derivs = (long_curve_shapes *
                exp_neg_v *
                small_powered_term /
                (powered_term - 1))
      # Use L'Hopitals rule to deal with overflow from v --> -inf
      # From plots, the assignment below may also correctly handle cases where we
      # have overflow from moderate v (say |v| <= 10) and large shape parameters.
      too_big_idx = (np.isposinf(derivs) +
                     np.isposinf(exp_neg_v) +
                     np.isposinf(powered_term) +
                     np.isposinf(small_powered_term)).astype(bool)
      derivs[too_big_idx] = long_curve_shapes[too_big_idx]
      # Use L'Hopitals rule to deal with underflow from v --> inf
      too_small_idx = np.where((exp_neg_v == 0) | (powered_term - 1 == 0))
      derivs[too_small_idx] = 1.0
  
      # Assign the calculated derivatives to the output array
      output_array.data = derivs
      assert output_array.shape == (systematic_utilities.shape[0],
                                    systematic_utilities.shape[0])
  
      # Return the matrix of dh_dv. Note the off-diagonal entries are zero
      # because each transformation only depends on its value of v and no others
      return output_array