code: def from_np(
      ndarray_or_container: Union[np.ndarray, Dict, List, Tuple, Set]
  ) -> Any:
      """Convert a ndarray or a container to tensor."""
      return apply_to_type(
          lambda x: isinstance(x, np.ndarray),
          lambda x: torch.from_numpy(x),
          ndarray_or_container,
      )
  
file_path: fairscale/fairscale/internal/containers.py
imports: from collections import OrderedDict
  from typing import Any, Callable, Dict, List, NamedTuple, Optional, Set, Tuple, Union, cast
  import numpy
  import torch
  from torch.nn.utils.rnn import PackedSequence
label_desc: Use image node_id 4 for calling a global function with example usage: from_np(ndarray_or_container) and returns: apply_to_type