code: def check_has_length(
      arr,
      /,
      *,
      exact_length=None,
      min_length=None,
      max_length=None,
      must_be_1d=False,
      allow_scalars=False,
      name="Array",
  ):
      """Check if the length of an array meets specific requirements.
  
      Notes
      -----
      By default, this function operates on multidimensional arrays,
      where ``len(arr)`` may differ from the number of elements in the
      array. For one-dimensional cases (where ``len(arr) == arr.size``),
      set ``must_be_1D=True``.
  
      Parameters
      ----------
      arr : array_like
          Array to check.
  
      exact_length : int | array_like[int, ...]
          Check if the array has the given length. If multiple
          numbers are given, the array's length must match one of the
          numbers.
  
      min_length : int, optional
          Check if the array has this length or greater.
  
      max_length : int, optional
          Check if the array has this length or less.
  
      must_be_1d : bool, default: False
          If ``True``, check if the shape of the array is one-dimensional,
          i.e. that the array's shape is ``(1,)``.
  
      allow_scalars : bool, default: False
          If ``True``, a scalar input will be reshaped to have a length of
          1. Otherwise, the check will fail since a scalar does not
          have a length.
  
      name : str, default: "Array"
          Variable name to use in the error messages if any are raised.
  
      Raises
      ------
      ValueError
          If the array's length is outside the specified range.
  
      See Also
      --------
      check_has_shape
  
      Examples
      --------
      Check if an array has a length of 2 or 3.
  
      >>> import pyvista.core.input_validation as valid
      >>> valid.check_has_length([1, 2], exact_length=[2, 3])
  
      Check if an array has a minimum length of 3.
  
      >>> valid.check_has_length((1, 2, 3), min_length=3)
  
      Check if a multidimensional array has a maximum length of 2.
  
      >>> valid.check_has_length([[1, 2, 3], [4, 5, 6]], max_length=2)
  
      """
      if allow_scalars:
          # Reshape to 1D
          if isinstance(arr, np.ndarray) and arr.ndim == 0:
              arr = [arr.tolist()]
          elif isinstance(arr, Number):
              arr = [arr]
      check_is_instance(arr, (Sequence, np.ndarray), name=name)
  
      if must_be_1d:
          check_has_shape(arr, shape=(-1))
  
      if exact_length is not None:
          exact_length = np.array(exact_length)
          check_is_integerlike(exact_length, name="'exact_length'")
          if len(arr) not in exact_length:
              raise ValueError(
                  f"{name} must have a length equal to any of: {exact_length}. "
                  f"Got length {len(arr)} instead."
              )
  
      # Validate min/max length
      if min_length is not None:
          min_length = cast_to_ndarray(min_length)
          check_is_scalar(min_length, name="Min length")
          check_is_real(min_length, name="Min length")
      if max_length is not None:
          max_length = cast_to_ndarray(max_length)
          check_is_scalar(max_length, name="Max length")
          check_is_real(max_length, name="Max length")
      if min_length is not None and max_length is not None:
          check_is_sorted((min_length, max_length), name="Range")
  
      if min_length is not None:
          if len(arr) < min_length:
              raise ValueError(
                  f"{name} must have a minimum length of {min_length}. "
                  f"Got length {len(arr)} instead."
              )
      if max_length is not None:
          if len(arr) > max_length:
              raise ValueError(
                  f"{name} must have a maximum length of {max_length}. "
                  f"Got length {len(arr)} instead."
              )
  
imports: from collections.abc import Iterable, Sequence
  from numbers import Number
  from typing import Tuple, Union, get_args, get_origin
  import numpy
  from pyvista.core.utilities.arrays import cast_to_ndarray
label_desc: Use image node_id 22 for calling a global function with example usage: check_has_length() without return types