code: def putmask_without_repeat(
      values: np.ndarray, mask: npt.NDArray[np.bool_], new: Any
  ) -> None:
      """
      np.putmask will truncate or repeat if `new` is a listlike with
      len(new) != len(values).  We require an exact match.
  
      Parameters
      ----------
      values : np.ndarray
      mask : np.ndarray[bool]
      new : Any
      """
      if np_version_under1p21:
          new = setitem_datetimelike_compat(values, mask.sum(), new)
  
      if getattr(new, "ndim", 0) >= 1:
          new = new.astype(values.dtype, copy=False)
  
      # TODO: this prob needs some better checking for 2D cases
      nlocs = mask.sum()
      if (
          nlocs > 0
          and is_list_like(new)
          and getattr(new, "ndim", 1) == 1
      ):
          shape = np.shape(new)
          # np.shape compat for if setitem_datetimelike_compat
          #  changed arraylike to list e.g. test_where_dt64_2d
          if nlocs == shape[-1]:
              # GH#30567
              # If length of ``new`` is less than the length of ``values``,
              # `np.putmask` would first repeat the ``new`` array and then
              # assign the masked values hence produces incorrect result.
              # `np.place` on the other hand uses the ``new`` values at it is
              # to place in the masked locations of ``values``
              np.place(values, mask, new)
              # i.e. values[mask] = new
          elif mask.shape[-1] == shape[-1] or shape[-1] == 1:
              np.putmask(values, mask, new)
          else:
              raise ValueError(
                  "cannot assign mismatch length to masked array"
              )
      else:
          np.putmask(values, mask, new)
  
file_path: catboost/contrib/python/pandas/py3/pandas/core/array_algos/putmask.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any
  import numpy
  from pandas._libs import lib
  from pandas._typing import ArrayLike, npt
  from pandas.compat import np_version_under1p21
  from pandas.core.dtypes.cast import infer_dtype_from
  from pandas.core.dtypes.common import is_list_like
  from pandas.core.arrays import ExtensionArray
label_desc: Use image node_id 2 for calling a global function with example usage: putmask_without_repeat(values, mask, new) without return types