code: def coerce_2_tensor(value: Union[float, List[float]], values: dict):
      if value is None:
          return value
      framework = values.get("backend") or values.get("flavour")
      if framework is None:
          raise ValueError(
              "`coerce_2tensor` failed since no framework identified."
          )
      elif framework == Framework.TENSORFLOW and has_tensorflow:
          return tf.convert_to_tensor(value)
      elif (framework == Framework.PYTORCH and has_pytorch) or (
          framework == Framework.KEOPS and has_keops
      ):
          return torch.tensor(value)
      else:
          # Error should not be raised since `flavour` should have already been validated.
          raise ImportError(
              f"Cannot coerce to {framework} Tensor since {framework} is not installed."
          )
  
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 4 for calling a global function with example usage: coerce_2_tensor(value, values) and returns: value, tf, torch