code: def process_opacity(
      mesh, opacity, preference, n_colors, scalars, use_transparency
  ):
      """Process opacity.
  
      This function accepts an opacity string or array and always
      returns an array that can be applied to a dataset for plotting.
  
      Parameters
      ----------
      mesh : pyvista.DataSet
          Dataset to process the opacity for.
  
      opacity : str, sequence
          String or array.  If string, can be a ``str`` name of a
          predefined mapping such as ``'linear'``, ``'geom'``,
          ``'sigmoid'``, ``'sigmoid3-10'``, or the key of a cell or
          point data array.
  
      preference : str
          When ``mesh.n_points == mesh.n_cells``, this parameter
          sets how the scalars will be mapped to the mesh. If
          ``'point'``, causes the scalars will be associated with
          the mesh points.  Can be either ``'point'`` or
          ``'cell'``.
  
      n_colors : int
          Number of colors to use when displaying the opacity.
  
      scalars : numpy.ndarray
          Dataset scalars.
  
      use_transparency : bool
          Invert the opacity mappings and make the values correspond
          to transparency.
  
      Returns
      -------
      custom_opac : bool
          If using custom opacity.
  
      opacity : numpy.ndarray
          Array containing the opacity.
  
      """
      custom_opac = False
      if isinstance(opacity, str):
          try:
              # Get array from mesh
              opacity = get_array(
                  mesh, opacity, preference=preference, err=True
              )
              if np.any(opacity > 1):
                  warnings.warn("Opacity scalars contain values over 1")
              if np.any(opacity < 0):
                  warnings.warn(
                      "Opacity scalars contain values less than 0"
                  )
              custom_opac = True
          except KeyError:
              # Or get opacity transfer function (e.g. "linear")
              opacity = opacity_transfer_function(opacity, n_colors)
          else:
              if scalars.shape[0] != opacity.shape[0]:
                  raise ValueError(
                      "Opacity array and scalars array must have the same number of elements."
                  )
      elif isinstance(opacity, (np.ndarray, list, tuple)):
          opacity = np.asanyarray(opacity)
          if opacity.shape[0] in [mesh.n_cells, mesh.n_points]:
              # User could pass an array of opacities for every point/cell
              custom_opac = True
          else:
              opacity = opacity_transfer_function(opacity, n_colors)
  
      if use_transparency:
          if np.max(opacity) <= 1.0:
              opacity = 1 - opacity
          elif isinstance(opacity, np.ndarray):
              opacity = 255 - opacity
  
      return custom_opac, opacity
  
file_path: pyvista/pyvista/plotting/_plotting.py
imports: import warnings
  import numpy
  import pyvista
  from pyvista.core.errors import PyVistaDeprecationWarning
  from pyvista.core.utilities.arrays import get_array
  from pyvista.core.utilities.misc import assert_empty_kwargs
  from .colors import Color
  from .opts import InterpolationType
  from .tools import opacity_transfer_function
label_desc: Use image node_id 2 for calling a global function with example usage: process_opacity(mesh, opacity, preference, n_colors, scalars, use_transparency) and returns: custom_opac,  opacity