code: def sig_replace_leading_parameters(
      s: inspect.Signature, n: int, new_params: list[inspect.Parameter]
  ) -> inspect.Signature:
      """Replace the first n positional parameters of a signature."""
      p = list(s.parameters.values())
      for i in range(n):
          if i >= len(p) or p[i].kind not in {
              inspect.Parameter.POSITIONAL_ONLY,
              inspect.Parameter.POSITIONAL_OR_KEYWORD,
          }:
              break  # not enough arguments (or args in VARARGS that can't be counted)
      else:
          i = n
      return inspect.Signature(
          parameters=new_params + p[i:],
          return_annotation=s.return_annotation,
          __validate_parameters__=False,
      )
  
imports: from collections.abc import Mapping
  import inspect
  from typing import Any, Callable, NamedTuple, Optional, TypeVar, Union
  from haiku._src import analytics
  from haiku._src import base
  from haiku._src import data_structures
  from haiku._src import typing
  import jax
label_desc: Use image node_id 1 for calling a global function with example usage: sig_replace_leading_parameters(s, n, new_params) and returns: inspect