code: def convert_array(arr, name=None, deep=False, array_type=None):
      """Convert a NumPy array to a vtkDataArray or vice versa.
  
      Parameters
      ----------
      arr : np.ndarray | vtkDataArray
          A numpy array or vtkDataArry to convert.
      name : str, optional
          The name of the data array for VTK.
      deep : bool, default: False
          If input is numpy array then deep copy values.
      array_type : int, optional
          VTK array type ID as specified in specified in ``vtkType.h``.
  
      Returns
      -------
      vtkDataArray or numpy.ndarray
          The converted array.  If input is a :class:`numpy.ndarray` then
          returns ``vtkDataArray`` or is input is ``vtkDataArray`` then
          returns NumPy ``ndarray``.
  
      """
      if arr is None:
          return
      if isinstance(arr, (list, tuple)):
          arr = np.array(arr)
      if isinstance(arr, np.ndarray):
          if arr.dtype == np.dtype("O"):
              arr = arr.astype("|S")
          arr = np.ascontiguousarray(arr)
          if arr.dtype.type in (np.str_, np.bytes_):
              # This handles strings
              vtk_data = convert_string_array(arr)
          else:
              # This will handle numerical data
              arr = np.ascontiguousarray(arr)
              vtk_data = _vtk.numpy_to_vtk(
                  num_array=arr, deep=deep, array_type=array_type
              )
          if isinstance(name, str):
              vtk_data.SetName(name)
          return vtk_data
      # Otherwise input must be a vtkDataArray
      if not isinstance(
          arr,
          (_vtk.vtkDataArray, _vtk.vtkBitArray, _vtk.vtkStringArray),
      ):
          raise TypeError(f"Invalid input array type ({type(arr)}).")
      # Handle booleans
      if isinstance(arr, _vtk.vtkBitArray):
          arr = vtk_bit_array_to_char(arr)
      # Handle string arrays
      if isinstance(arr, _vtk.vtkStringArray):
          return convert_string_array(arr)
      # Convert from vtkDataArry to NumPy
      return _vtk.vtk_to_numpy(arr)
  
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 6 for calling a global function with example usage: convert_array(arr, name, deep, array_type) and returns: _vtk, vtk_data, convert_string_array