code: def _lazywhere(cond, arrays, f, fillvalue=None, f2=None):
      """
      np.where(cond, x, fillvalue) always evaluates x even where cond is False.
      This one only evaluates f(arr1[cond], arr2[cond], ...).
  
      Examples
      --------
      >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
      >>> def f(a, b):
      ...     return a*b
      >>> _lazywhere(a > 2, (a, b), f, np.nan)
      array([ nan,  nan,  21.,  32.])
  
      Notice, it assumes that all `arrays` are of the same shape, or can be
      broadcasted together.
  
      """
      cond = np.asarray(cond)
      if fillvalue is None:
          if f2 is None:
              raise ValueError("One of (fillvalue, f2) must be given.")
          else:
              fillvalue = np.nan
      else:
          if f2 is not None:
              raise ValueError(
                  "Only one of (fillvalue, f2) can be given."
              )
  
      args = np.broadcast_arrays(cond, *arrays)
      cond, arrays = args[0], args[1:]
      temp = tuple(np.extract(cond, arr) for arr in arrays)
      tcode = np.mintypecode([a.dtype.char for a in arrays])
      out = np.full(
          np.shape(arrays[0]), fill_value=fillvalue, dtype=tcode
      )
      np.place(out, cond, f(*temp))
      if f2 is not None:
          temp = tuple(np.extract(~cond, arr) for arr in arrays)
          np.place(out, ~cond, f2(*temp))
  
      return out
  
imports: from contextlib import contextmanager
  import functools
  import operator
  import sys
  import warnings
  import numbers
  from collections import namedtuple
  import inspect
  import math
  from typing import Optional, Union, TYPE_CHECKING, TypeVar
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _lazywhere(cond, arrays, f, fillvalue, f2) and returns: out