code: def fill_invalid(obj: int | float | bool | T) -> T:
      if isinstance(obj, (int, float, bool)):
          return fill_invalid(np.array(obj))
      if hasattr(obj, "dtype"):
          if isinstance(obj, np.ndarray):
              if np.issubdtype(obj.dtype, np.floating):
                  return np.full_like(obj, np.nan)
              return np.full_like(obj, np.iinfo(obj.dtype).max)
          # dealing with corner cases that numpy number is not supported by tianshou's sharray
          return fill_invalid(np.array(obj))
      elif isinstance(obj, dict):
          return {k: fill_invalid(v) for k, v in obj.items()}
      elif isinstance(obj, list):
          return [fill_invalid(v) for v in obj]
      elif isinstance(obj, tuple):
          return tuple(fill_invalid(v) for v in obj)
      raise ValueError(f"Unsupported value to fill with invalid: {obj}")
  
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 1 for calling a global function with example usage: fill_invalid(obj) and returns: fill_invalid, fill_invalid, np, unknown, np, unknown, tuple