code: def ts_size(ts, be=None):
      """Returns actual time series size.
  
      Final timesteps that have `NaN` values for all dimensions will be removed
      from the count. Infinity and negative infinity ar considered valid time
      series values.
  
      Parameters
      ----------
      ts : array-like
          A time series.
      be : Backend object or string or None
          Backend. If `be` is an instance of the class `NumPyBackend` or the string `"numpy"`,
          the NumPy backend is used.
          If `be` is an instance of the class `PyTorchBackend` or the string `"pytorch"`,
          the PyTorch backend is used.
          If `be` is `None`, the backend is determined by the input arrays.
          See our :ref:`dedicated user-guide page <backend>` for more information.
  
      Returns
      -------
      int
          Actual size of the time series.
  
      Examples
      --------
      >>> ts_size([1, 2, 3, numpy.nan])
      3
      >>> ts_size([1, numpy.nan])
      1
      >>> ts_size([numpy.nan])
      0
      >>> ts_size([[1, 2],
      ...          [2, 3],
      ...          [3, 4],
      ...          [numpy.nan, 2],
      ...          [numpy.nan, numpy.nan]])
      4
      >>> ts_size([numpy.nan, 3, numpy.inf, numpy.nan])
      3
      """
      be = instantiate_backend(be, ts)
      ts_ = to_time_series(ts, be=be)
      sz = be.shape(ts_)[0]
      while sz > 0 and be.all(be.isnan(ts_[sz - 1])):
          sz -= 1
      return sz
  
imports: import warnings
  from io import StringIO
  import numpy
  from sklearn.base import TransformerMixin
  from sklearn.utils import column_or_1d
  from sklearn.utils.validation import check_is_fitted
  from tslearn.backend import instantiate_backend
  from tslearn.bases import TimeSeriesBaseEstimator
label_desc: Use image node_id 9 for calling a global function with example usage: ts_size(ts, be) and returns: sz