code: def is_invalid(arr: int | float | bool | T) -> bool:
      if isinstance(arr, np.ndarray):
          if np.issubdtype(arr.dtype, np.floating):
              return np.isnan(arr).all()
          return cast(
              bool,
              cast(np.ndarray, np.iinfo(arr.dtype).max == arr).all(),
          )
      if isinstance(arr, dict):
          return all(is_invalid(o) for o in arr.values())
      if isinstance(arr, (list, tuple)):
          return all(is_invalid(o) for o in arr)
      if isinstance(arr, (int, float, bool, np.number)):
          return is_invalid(np.array(arr))
      return True
  
imports: from __future__ import annotations
  import copy
  import warnings
  from contextlib import contextmanager
  from typing import Any, Callable, Dict, Generator, List, Optional, Set, Tuple, Type, Union, cast
  import gym
  import numpy
  from tianshou.env import BaseVectorEnv, DummyVectorEnv, ShmemVectorEnv, SubprocVectorEnv
  from qlib.typehint import Literal
  from .log import LogWriter
label_desc: Use image node_id 2 for calling a global function with example usage: is_invalid(arr) and returns: True, cast, all, all, is_invalid, np