code: def _format_target(
      target: Union[None, int, list, np.ndarray], nb_samples: int
  ) -> Union[None, np.ndarray]:
      """
      Formats target to return a np.array.
  
      Parameters
      ----------
      target
          Original target.
      nb_samples
          Number of samples in the batch.
  
      Returns
      -------
      Formatted target as a np.array.
  
      """
      if target is not None:
          if isinstance(target, int):
              target = np.array([target for _ in range(nb_samples)])
          elif isinstance(target, list):
              target = np.array(target)
          elif isinstance(target, np.ndarray):
              pass
          else:
              raise NotImplementedError
  
      return target
  
imports: import copy
  import logging
  import string
  import warnings
  from enum import Enum
  from typing import Callable, List, Optional, Tuple, Union, cast
  import numpy
  import tensorflow
  from alibi.api.defaults import DEFAULT_DATA_INTGRAD, DEFAULT_META_INTGRAD
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.utils.approximation_methods import approximation_parameters
label_desc: Use image node_id 10 for calling a global function with example usage: _format_target(target, nb_samples) and returns: target