code: def find_label_issues_batched(
      labels: Optional[LabelLike] = None,
      pred_probs: Optional[np.ndarray] = None,
      *,
      labels_file: Optional[str] = None,
      pred_probs_file: Optional[str] = None,
      batch_size: int = 10000,
      n_jobs: Optional[int] = 1,
      verbose: bool = True,
      quality_score_kwargs: Optional[dict] = None,
      num_issue_kwargs: Optional[dict] = None,
      return_mask: bool = False,
  ) -> np.ndarray:
      """
      Variant of :py:func:`filter.find_label_issues <cleanlab.filter.find_label_issues>`
      that requires less memory by reading from `pred_probs`, `labels` in mini-batches.
      To avoid loading big `pred_probs`, `labels` arrays into memory,
      provide these as memory-mapped objects like Zarr arrays or memmap arrays instead of regular numpy arrays.
      See: https://pythonspeed.com/articles/mmap-vs-zarr-hdf5/
  
      With default settings, the results returned from this method closely approximate those returned from:
      ``cleanlab.filter.find_label_issues(..., filter_by="low_self_confidence", return_indices_ranked_by="self_confidence")``
  
      This function internally implements the example usage script of the ``LabelInspector`` class,
      but you can further customize that script by running it yourself instead of this function.
      See the documentation of ``LabelInspector`` to learn more about how this method works internally.
  
      Parameters
      ----------
      labels: np.ndarray-like object, optional
        1D array of given class labels for each example in the dataset, (int) values in ``0,1,2,...,K-1``.
        To avoid loading big objects into memory, you should pass this as a memory-mapped object like:
        Zarr array loaded with ``zarr.convenience.open(YOURFILE.zarr, mode="r")``,
        or memmap array loaded with ``np.load(YOURFILE.npy, mmap_mode="r")``.
  
        Tip: You can save an existing numpy array to Zarr via: ``zarr.convenience.save_array(YOURFILE.zarr, your_array)``,
        or to .npy file that can be loaded with mmap via: ``np.save(YOURFILE.npy, your_array)``.
  
      pred_probs: np.ndarray-like object, optional
        2D array of model-predicted class probabilities (floats) for each example in the dataset.
        To avoid loading big objects into memory, you should pass this as a memory-mapped object like:
        Zarr array loaded with ``zarr.convenience.open(YOURFILE.zarr, mode="r")``
        or memmap array loaded with ``np.load(YOURFILE.npy, mmap_mode="r")``.
  
      labels_file: str, optional
        Specify this instead of `labels` if you want this method to load from file for you into a memmap array.
        Path to .npy file where the entire 1D `labels` numpy array is stored on disk (list format is not supported).
        This is loaded using: ``np.load(labels_file, mmap_mode="r")``
        so make sure this file was created via: ``np.save()`` or other compatible methods (.npz not supported).
  
      pred_probs_file: str, optional
        Specify this instead of `pred_probs` if you want this method to load from file for you into a memmap array.
        Path to .npy file where the entire `pred_probs` numpy array is stored on disk.
        This is loaded using: ``np.load(pred_probs_file, mmap_mode="r")``
        so make sure this file was created via: ``np.save()`` or other compatible methods (.npz not supported).
  
      batch_size : int, optional
        Size of mini-batches to use for estimating the label issues.
        To maximize efficiency, try to use the largest `batch_size` your memory allows.
  
      n_jobs: int, optional
        Number of processes for multiprocessing (default value = 1). Only used on Linux.
        If `n_jobs=None`, will use either the number of: physical cores if psutil is installed, or logical cores otherwise.
  
      verbose : bool, optional
        Whether to suppress print statements or not.
  
      quality_score_kwargs : dict, optional
        Keyword arguments to pass into :py:func:`rank.get_label_quality_scores <cleanlab.rank.get_label_quality_scores>`.
  
      num_issue_kwargs : dict, optional
        Keyword arguments to :py:func:`count.num_label_issues <cleanlab.count.num_label_issues>`
        to control estimation of the number of label issues.
        The only supported kwarg here for now is: `estimation_method`.
      return_mask : bool, optional
         Determines what is returned by this method: If `return_mask=True`, return a boolean mask.
         If `False`, return a list of indices specifying examples with label issues, sorted by label quality score.
  
      Returns
      -------
      label_issues : np.ndarray
        If `return_mask` is `True`, returns a boolean **mask** for the entire dataset
        where ``True`` represents a label issue and ``False`` represents an example that is
        accurately labeled with high confidence.
        If `return_mask` is `False`, returns an array containing **indices** of examples identified to have
        label issues (i.e. those indices where the mask would be ``True``), sorted by likelihood that the corresponding label is correct.
      --------
      >>> batch_size = 10000  # for efficiency, set this to as large of a value as your memory can handle
      >>> # Just demonstrating how to save your existing numpy labels, pred_probs arrays to compatible .npy files:
      >>> np.save("LABELS.npy", labels_array)
      >>> np.save("PREDPROBS.npy", pred_probs_array)
      >>> # You can load these back into memmap arrays via: labels = np.load("LABELS.npy", mmap_mode="r")
      >>> # and then run this method on the memmap arrays, or just run it directly on the .npy files like this:
      >>> issues = find_label_issues_batched(labels_file="LABELS.npy", pred_probs_file="PREDPROBS.npy", batch_size=batch_size)
      >>> # This method also works with Zarr arrays:
      >>> import zarr
      >>> # Just demonstrating how to save your existing numpy labels, pred_probs arrays to compatible .zarr files:
      >>> zarr.convenience.save_array("LABELS.zarr", labels_array)
      >>> zarr.convenience.save_array("PREDPROBS.zarr", pred_probs_array)
      >>> # You can load from such files into Zarr arrays:
      >>> labels = zarr.convenience.open("LABELS.zarr", mode="r")
      >>> pred_probs = zarr.convenience.open("PREDPROBS.zarr", mode="r")
      >>> # This method can be directly run on Zarr arrays, memmap arrays, or regular numpy arrays:
      >>> issues = find_label_issues_batched(labels=labels, pred_probs=pred_probs, batch_size=batch_size)
      """
      if labels_file is not None:
          if labels is not None:
              raise ValueError(
                  "only specify one of: `labels` or `labels_file`"
              )
          if not isinstance(labels_file, str):
              raise ValueError(
                  "labels_file must be str specifying path to .npy file containing the array of labels"
              )
          labels = np.load(labels_file, mmap_mode="r")
          assert isinstance(labels, np.ndarray)
  
      if pred_probs_file is not None:
          if pred_probs is not None:
              raise ValueError(
                  "only specify one of: `pred_probs` or `pred_probs_file`"
              )
          if not isinstance(pred_probs_file, str):
              raise ValueError(
                  "pred_probs_file must be str specifying path to .npy file containing 2D array of pred_probs"
              )
          pred_probs = np.load(pred_probs_file, mmap_mode="r")
          assert isinstance(pred_probs, np.ndarray)
          if verbose:
              print(
                  f"mmap-loaded numpy arrays have: {len(pred_probs)} examples, {pred_probs.shape[1]} classes"
              )
      if labels is None:
          raise ValueError(
              "must provide one of: `labels` or `labels_file`"
          )
      if pred_probs is None:
          raise ValueError(
              "must provide one of: `pred_probs` or `pred_probs_file`"
          )
  
      assert pred_probs is not None
      if len(labels) != len(pred_probs):
          raise ValueError(
              f"len(labels)={len(labels)} does not match len(pred_probs)={len(pred_probs)}. Perhaps an issue loading mmap numpy arrays from file."
          )
      lab = LabelInspector(
          num_class=pred_probs.shape[1],
          verbose=verbose,
          n_jobs=n_jobs,
          quality_score_kwargs=quality_score_kwargs,
          num_issue_kwargs=num_issue_kwargs,
      )
      n = len(labels)
      if verbose:
          from tqdm.auto import tqdm
  
          pbar = tqdm(
              desc="number of examples processed for estimating thresholds",
              total=n,
          )
      i = 0
      while i < n:
          end_index = i + batch_size
          labels_batch = labels[i:end_index]
          pred_probs_batch = pred_probs[i:end_index, :]
          i = end_index
          lab.update_confident_thresholds(
              labels_batch, pred_probs_batch
          )
          if verbose:
              pbar.update(batch_size)
  
      # Next evaluate the quality of the labels (run this on full dataset you want to evaluate):
      if verbose:
          pbar.close()
          pbar = tqdm(
              desc="number of examples processed for checking labels",
              total=n,
          )
      i = 0
      while i < n:
          end_index = i + batch_size
          labels_batch = labels[i:end_index]
          pred_probs_batch = pred_probs[i:end_index, :]
          i = end_index
          _ = lab.score_label_quality(labels_batch, pred_probs_batch)
          if verbose:
              pbar.update(batch_size)
  
      if verbose:
          pbar.close()
  
      label_issues_indices = lab.get_label_issues()
      label_issues_mask = np.zeros(len(labels), dtype=bool)
      label_issues_mask[label_issues_indices] = True
      mask = _reduce_issues(pred_probs=pred_probs, labels=labels)
      label_issues_mask[mask] = False
      if return_mask:
          return label_issues_mask
      return np.where(label_issues_mask)[0]
  
imports: import numpy
  from typing import Optional, List, Tuple, Any
  from cleanlab.count import get_confident_thresholds, _reduce_issues
  from cleanlab.rank import find_top_issues, _compute_label_quality_scores
  from cleanlab.typing import LabelLike
  from cleanlab.internal.util import value_counts_fill_missing_classes
  from cleanlab.internal.constants import CONFIDENT_THRESHOLDS_LOWER_BOUND, FLOATING_POINT_COMPARISON, CLIPPING_LOWER_BOUND
  import platform
  import multiprocessing
label_desc: Use image node_id 1 for calling a global function with example usage: find_label_issues_batched(labels, pred_probs) and returns: np, label_issues_mask