code: def _validate_gradient_methods(tape, method, diff_methods):
      """Validates if the gradient method requested is supported by the trainable
      parameters of a tape, and returns the allowed parameter gradient methods.
      """
  
      # check and raise an error if any parameters are non-differentiable
      nondiff_params = [
          tape.trainable_params[idx]
          for idx, m in diff_methods.items()
          if m is None
      ]
      if nondiff_params:
          raise ValueError(
              f"Cannot differentiate with respect to parameter(s) {nondiff_params}"
          )
  
      # If explicitly using analytic mode, ensure that all
      # parameters support analytic differentiation.
      numeric_params = [
          tape.trainable_params[idx]
          for idx, m in diff_methods.items()
          if m == "F"
      ]
      if method == "analytic" and numeric_params:
          raise ValueError(
              f"The analytic gradient method cannot be used with the parameter(s) {numeric_params}."
          )
  
imports: from functools import partial
  import warnings
  import pennylane
  from pennylane.transforms.tape_expand import expand_invalid_trainable
  from pennylane.measurements import MutualInfoMP, StateMP, VarianceMP, VnEntropyMP, ProbabilityMP
label_desc: Use image node_id 8 for calling a global function with example usage: _validate_gradient_methods(tape, method, diff_methods) without return types