code: def _calculate_t_distribution(  # pylint: disable=invalid-name
      sampling_data_list: List[Union[int, float, np.ndarray]],
      unsampled_data: Union[int, float, np.ndarray],
  ):
      """Calculate the confidence interval of the data.
  
      Args:
        sampling_data_list: A list of number or np.ndarray.
        unsampled_data: Individual number or np.ndarray. The format of the
          unsampled_data should match the format of the element inside
          sampling_data_list.
  
      Returns:
        Confidence Interval value stored inside
        types.ValueWithTDistribution.
      """
      if isinstance(sampling_data_list[0], (np.ndarray, list)):
          merged_data = sampling_data_list[0][:]
          if isinstance(sampling_data_list[0], np.ndarray):
              merged_data = merged_data.astype(object)
          for index in range(len(merged_data)):
              merged_data[index] = _calculate_t_distribution(
                  [data[index] for data in sampling_data_list],
                  unsampled_data[index],
              )
          return merged_data
      else:
          # Data has to be numeric. That means throw out nan values.
          sampling_data_list = [
              data for data in sampling_data_list if not np.isnan(data)
          ]
          n_samples = len(sampling_data_list)
          if n_samples:
              sample_mean = np.mean(sampling_data_list)
              sample_std = np.std(sampling_data_list, ddof=1)
              return types.ValueWithTDistribution(
                  sample_mean, sample_std, n_samples - 1, unsampled_data
              )
          else:
              return types.ValueWithTDistribution(
                  float("nan"), float("nan"), -1, float("nan")
              )
  
file_path: model-analysis/tensorflow_model_analysis/evaluators/legacy_poisson_bootstrap.py
imports: from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Type, Union
  import apache_beam
  import numpy
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.slicer import slicer_lib
  from google.protobuf import message
label_desc: Use image node_id 2 for calling a global function with example usage: _calculate_t_distribution(sampling_data_list, unsampled_data) and returns: merged_data, types, types