class_docstr: Find appropriate date and adjust date.
class_docstr_tok: ["Find","appropriate","date","and","adjust","date","."]
docstr: Truncate the segment based on the test_start date
  
  Parameters
  ----------
  segment : tuple
      time segment
  test_start
  days : int
      The trading days to be truncated
      the data in this segment may need 'days' data
      `days` are based on the `test_start`.
      For example, if the label contains the information of 2 days in the near future, the prediction horizon 1 day.
      (e.g. the prediction target is `Ref($close, -2)/Ref($close, -1) - 1`)
      the days should be 2 + 1 == 3 days.
  
  Returns
  ---------
  tuple: new segment
docstr_tok: ["Truncate","the","segment","based","on","the","test_start","date","Parameters","--","--","--","--","--","segment",":","tuple","time","segment","test_start","days",":","int","The","trading","days","to","be","truncated","the","data","in","this","segment","may","need","'days","'","data","`","days","`","are","based","on","the","`","test_start","`",".","For","example",",","if","the","label","contains","the","information","of","2","days","in","the","near","future",",","the","prediction","horizon","1","day",".","(","e.g",".","the","prediction","target","is","`","Ref","(","$","close",",","-2",")","\/Ref","(","$","close",",","-1",")","-","1","`",")","the","days","should","be","2","+","1","==","3","days",".","Returns","--","--","--","--","-","tuple",":","new","segment"]
code: def truncate(self, segment: tuple, test_start, days: int) -> tuple:
      """
      Truncate the segment based on the test_start date
  
      Parameters
      ----------
      segment : tuple
          time segment
      test_start
      days : int
          The trading days to be truncated
          the data in this segment may need 'days' data
          `days` are based on the `test_start`.
          For example, if the label contains the information of 2 days in the near future, the prediction horizon 1 day.
          (e.g. the prediction target is `Ref($close, -2)/Ref($close, -1) - 1`)
          the days should be 2 + 1 == 3 days.
  
      Returns
      ---------
      tuple: new segment
      """
      test_idx = self.align_idx(test_start)
      if isinstance(segment, tuple):
          new_seg = []
          for time_point in segment:
              tp_idx = min(self.align_idx(time_point), test_idx - days)
              assert tp_idx > 0
              new_seg.append(self.get(tp_idx))
          return tuple(new_seg)
      else:
          raise NotImplementedError(
              f"This type of input is not supported"
          )
  
imports: import bisect
  from copy import deepcopy
  import pandas
  from qlib.data import D
  from qlib.utils import hash_args
  from qlib.utils.mod import init_instance_by_config
  from qlib.workflow import R
  from qlib.config import C
  from qlib.log import get_module_logger
  from pymongo import MongoClient
  from pymongo.database import Database
  from typing import Union
  from pathlib import Path
label_desc: Use image node_id 9 for calling the TimeAdjuster obj's underlying member method code with example usage: obj.truncate(segment, test_start, days) and returns: tuple