code: def _coerce_2_ndarray(
      cls: Type, val: Any, field: ModelField
  ) -> np.ndarray:
      if field.sub_fields is not None:
          dtype_field = field.sub_fields[0]
          return np.asarray(val, dtype=dtype_field.type_)
      else:
          return np.asarray(val)
  
file_path: alibi-detect/alibi_detect/saving/validators.py
imports: import sys
  from typing import Any, Generic, Optional, Type, TypeVar, Union, List
  import numpy
  from numpy.lib import NumpyVersion
  from pydantic.fields import ModelField
  from alibi_detect.utils.frameworks import has_tensorflow, has_pytorch, has_keops, Framework
label_desc: Use image node_id 3 for calling a global function with example usage: _coerce_2_ndarray(cls, val, field) and returns: np, np