code: def _check_and_update_kwargs(
      version: str,
      record: TextClassificationRecord,
      sort_by: SortBy,
      kwargs: Dict,
  ):
      """Helper function to check and update the kwargs passed on to cleanlab's `get_noise_indices`.
  
      Args:
          version: version of cleanlab
          record: One of the records passed in the `find_label_error` function.
          sort_by: The sorting policy.
          kwargs: The passed on kwargs.
  
      Raises:
          ValueError: If not supported kwargs ('sorted_index_method') are passed on.
      """
      if "multi_label" in kwargs:
          warnings.warn(
              "You provided the kwarg 'multi_label', but it is determined automatically. "
              f"We will set it to '{record.multi_label}'."
          )
      kwargs["multi_label"] = record.multi_label
  
      if parse_version(version) < parse_version("2.0"):
          if "sorted_index_method" in kwargs:
              raise ValueError(
                  "The 'sorted_index_method' kwarg is not supported, please use 'sort_by' instead."
              )
          kwargs["sorted_index_method"] = "normalized_margin"
          if sort_by is SortBy.PREDICTION:
              kwargs["sorted_index_method"] = "prob_given_label"
          elif sort_by is SortBy.NONE:
              kwargs["sorted_index_method"] = None
      else:
          if "return_indices_ranked_by" in kwargs:
              raise ValueError(
                  "The 'return_indices_ranked_by' kwarg is not supported, please use 'sort_by' instead."
              )
          kwargs["return_indices_ranked_by"] = "normalized_margin"
          if sort_by is SortBy.PREDICTION:
              kwargs["return_indices_ranked_by"] = "self_confidence"
          elif sort_by is SortBy.NONE:
              kwargs["return_indices_ranked_by"] = None
          # TODO: Remove this once https://github.com/cleanlab/cleanlab/issues/243 is solved
          elif kwargs["multi_label"]:
              warnings.warn(
                  "With cleanlab v2 and multi-label records there is an issue sorting records by 'likelihood' "
                  "(https://github.com/cleanlab/cleanlab/issues/243). We will sort by 'prediction' instead."
              )
              kwargs["return_indices_ranked_by"] = "self_confidence"
  
imports: import logging
  import warnings
  from enum import Enum
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  from pkg_resources import parse_version
  from argilla.client.datasets import DatasetForTextClassification
  from argilla.client.models import TextClassificationRecord
  from argilla.utils.dependency import requires_dependencies
label_desc: Use image node_id 2 for calling a global function with example usage: _check_and_update_kwargs(version, record, sort_by, kwargs) without return types