code: def tensorflow2xp(
      tf_tensor: "tf.Tensor", *, ops: Optional["Ops"] = None  # type: ignore
  ) -> ArrayXd:  # pragma: no cover
      """Convert a Tensorflow tensor to numpy or cupy tensor depending on the `ops` parameter.
      If `ops` is `None`, the type of the resultant tensor will be determined by the source tensor's device.
      """
      from .api import NumpyOps
  
      assert_tensorflow_installed()
      if is_tensorflow_gpu_array(tf_tensor):
          if isinstance(ops, NumpyOps):
              return tf_tensor.numpy()
          else:
              dlpack_tensor = tf.experimental.dlpack.to_dlpack(tf_tensor)  # type: ignore
              return cupy_from_dlpack(dlpack_tensor)
      else:
          if isinstance(ops, NumpyOps) or ops is None:
              return tf_tensor.numpy()
          else:
              return cupy.asarray(tf_tensor.numpy())
  
imports: import contextlib
  import functools
  import inspect
  import os
  import platform
  import random
  import tempfile
  import threading
  from contextvars import ContextVar
  from dataclasses import dataclass
  from typing import Any, Callable, Dict, List, Mapping, Optional, Sequence, Tuple, TypeVar, Union, cast
  import numpy
  from packaging.version import Version
  from wasabi import table
  from .compat import cupy, cupy_from_dlpack, has_cupy, has_cupy_gpu, has_gpu, has_mxnet, has_tensorflow, has_torch, has_torch_cuda_gpu, has_torch_mps
  from .compat import mxnet
  from .compat import tensorflow
  from .compat import torch
  from typing import TYPE_CHECKING
  from .None import types
  from .types import ArgsKwargs, ArrayXd, FloatsXd, IntsXd, Padded, Ragged
label_desc: Use image node_id 32 for calling a global function with example usage: tensorflow2xp(tf_tensor) and returns: tf_tensor, cupy_from_dlpack, tf_tensor, cupy