code: def randomize_if_tensor(obj, batch_dim, batch_size):
      if isinstance(obj, torch.Tensor):
          new_obj = obj.clone().detach().contiguous()
          if (
              obj.numel() != 1
              and obj.dim() > batch_dim
              and obj.size(batch_dim) == batch_size
          ):
              if new_obj.dtype in torch_float_dtype:
                  # NOTE: this is a workaround to avoid relu/relu6 ...
                  randomize_tensor_inplace(new_obj, 0.1, 8.0)
              else:
                  randomize_tensor_inplace(new_obj)
          return new_obj
      else:
          try:
              return deepcopy(obj)
          except Exception:
              return obj
  
file_path: nni/nni/compression/speedup/utils.py
imports: from copy import deepcopy
  import logging
  from typing import Any, Dict, List, Tuple
  import torch
  from torch.fx.immutable_collections import immutable_dict, immutable_list
  from torch.utils._pytree import tree_map, tree_flatten, tree_unflatten, _register_pytree_node, Context
label_desc: Use image node_id 6 for calling a global function with example usage: randomize_if_tensor(obj, batch_dim, batch_size) and returns: new_obj, deepcopy, obj