code: def pipe(
      obj: _T,
      func: Callable[Concatenate[_T, P], T]
      | tuple[Callable[..., T], str],
      *args: Any,
      **kwargs: Any,
  ) -> T:
      """
      Apply a function ``func`` to object ``obj`` either by passing obj as the
      first argument to the function or, in the case that the func is a tuple,
      interpret the first element of the tuple as a function and pass the obj to
      that function as a keyword argument whose key is the value of the second
      element of the tuple.
  
      Parameters
      ----------
      func : callable or tuple of (callable, str)
          Function to apply to this object or, alternatively, a
          ``(callable, data_keyword)`` tuple where ``data_keyword`` is a
          string indicating the keyword of ``callable`` that expects the
          object.
      *args : iterable, optional
          Positional arguments passed into ``func``.
      **kwargs : dict, optional
          A dictionary of keyword arguments passed into ``func``.
  
      Returns
      -------
      object : the return type of ``func``.
      """
      if isinstance(func, tuple):
          # Assigning to func_ so pyright understands that it's a callable
          func_, target = func
          if target in kwargs:
              msg = f"{target} is both the pipe target and a keyword argument"
              raise ValueError(msg)
          kwargs[target] = obj
          return func_(*args, **kwargs)
      else:
          return func(obj, *args, **kwargs)
  
imports: from __future__ import annotations
  import builtins
  from collections import abc, defaultdict
  from collections.abc import Collection, Generator, Hashable, Iterable, Sequence
  import contextlib
  from functools import partial
  import inspect
  from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast, overload
  import warnings
  import numpy
  from pandas._libs import lib
  from pandas.compat.numpy import np_version_gte1p24
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
  from pandas.core.dtypes.common import is_bool_dtype, is_integer
  from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCMultiIndex, ABCSeries
  from pandas.core.dtypes.inference import iterable_not_string
label_desc: Use image node_id 29 for calling a global function with example usage: pipe(obj, func) and returns: func_, func