code: def _cast_nested_to_fp16(nested_dat):
      """Cast the nested input to fp16
  
      Parameters
      ----------
      dat
          The input nested data structure
  
      Returns
      -------
      output
          The casted output data
      """
      if isinstance(nested_dat, (mx.np.ndarray, np.ndarray)):
          if nested_dat.dtype == np.float32:
              return nested_dat.astype(np.float16)
          else:
              return nested_dat
      elif isinstance(nested_dat, list):
          return [_cast_nested_to_fp16(ele) for ele in nested_dat]
      elif isinstance(nested_dat, tuple):
          return tuple(
              [_cast_nested_to_fp16(ele) for ele in nested_dat]
          )
      else:
          raise NotImplementedError("Type is not supported!")
  
file_path: gluon-nlp/src/gluonnlp/utils/testing.py
imports: import numpy.testing
  import numpy
  import mxnet
  from mxnet.util import use_np
  from .parameter import move_to_ctx
label_desc: Use image node_id 5 for calling a global function with example usage: _cast_nested_to_fp16(nested_dat) and returns: nested_dat, nested_dat, unknown, tuple