code: def get_array_association(
      mesh, name, preference="cell", err=False
  ) -> FieldAssociation:
      """Return the array association.
  
      Parameters
      ----------
      mesh : Dataset
          Dataset to get the array association from.
  
      name : str
          The name of the array.
  
      preference : str, default: "cell"
          When scalars is specified, this is the preferred array type to
          search for in the dataset.  Must be either ``'point'``,
          ``'cell'``, or ``'field'``.
  
      err : bool, default: False
          Boolean to control whether to throw an error if array is not
          present.
  
      Returns
      -------
      pyvista.core.utilities.arrays.FieldAssociation
          Association of the array. If array is not present and ``err`` is
          ``False``, ``FieldAssociation.NONE`` is returned.
  
      """
      if isinstance(mesh, _vtk.vtkTable):
          arr = row_array(mesh, name)
          if arr is None and err:
              raise KeyError(
                  f"Data array ({name}) not present in this dataset."
              )
          return FieldAssociation.ROW
  
      # with multiple arrays, return the array preference if possible
      parr = point_array(mesh, name)
      carr = cell_array(mesh, name)
      farr = field_array(mesh, name)
      arrays = [parr, carr, farr]
      preferences = [
          FieldAssociation.POINT,
          FieldAssociation.CELL,
          FieldAssociation.NONE,
      ]
      preference = parse_field_choice(preference)
      if preference not in preferences:
          raise ValueError(f"Data field ({preference}) not supported.")
  
      matches = [
          pref
          for pref, array in zip(preferences, arrays)
          if array is not None
      ]
      # optionally raise if no match
      if not matches:
          if err:
              raise KeyError(
                  f"Data array ({name}) not present in this dataset."
              )
          return FieldAssociation.NONE
      # use preference if it applies
      if preference in matches:
          return preference
      # otherwise return first in order of point -> cell -> field
      return matches[0]
  
imports: import collections.abc
  import enum
  from itertools import product
  from typing import Optional, Tuple, Union
  import numpy
  import pyvista
  from pyvista.core import _vtk_core
  from pyvista.core._typing_core import Matrix, NumpyArray, TransformLike, Vector
  from pyvista.core.errors import AmbiguousDataError, MissingDataError
label_desc: Use image node_id 8 for calling a global function with example usage: get_array_association(mesh, name, preference, err) and returns: matches, FieldAssociation, FieldAssociation, preference